How to know if DirectoryEntry is a user or a group?
Off the top of my head: Have you considered checking Schema properties of the returned result? I'm thinking you could easily figure a group by using DirectoryEntry.SchemaEntry.Name
. It should return group
if your schema entry is a group.
Reference: MSDN: DirectoryEntry.SchemaEntry
Just out of curiosity and a bit off topic in your code above:
if (pathToAD.Length > 0)
objADAM = new DirectoryEntry();
else
objADAM = new DirectoryEntry(pathToAD);
objADAM.RefreshCache();
wouldn't you want to use pathToAD
IF the Length>0
?