What would be the best way in C# to use directory entry to find all users with the attribute wWWHomePage filled in.
I am able to see if a specific user has it but I have not used Directory Entry to search all users for something like this.
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, myDomain, Login.authUserName, Login.authPassword);
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, username);
if (user != null) {
DirectoryEntry de = (user.GetUnderlyingObject() as DirectoryEntry);
if (de != null) {
string whatIWant = de.Properties["wWWHomePage"].Value.ToString();
}
}
use
DirectoryEntrywithDirectorySearcherand specify the searchFilterto get what you want.the
Filtertemplate you want is :where
PROPERTY_NAMEis the property you want to search in, andSEARCH_TERMis the value. you could use the*as a wildcard search, it would give you all objects that has this property.here is a quick example :