G
greg.hart
Hello all,
I just wanted to see if someone can see something I am missing. This
code works, but does not seem to apply the filter. It pulls back all
the users whereas I am just looking for the ones that have name and
telephone populated and are not disabled. When I run this filter
directly inside the AD query tool I get the expected results. Just
doesn't seem to work right from my code. Thanks.
PrincipalContext ctx = new PrincipalContext(ContextType.Domain,
<Domain>,<UserName>,<Password>);
UserPrincipal u = new UserPrincipal(ctx);
u.AdvancedSearchFilter.Equals("(&(objectCategory=person)
(objectClass=user)(name=*)(telephoneNumber=*)(!userAccountControl:
1.2.840.113556.1.4.803:=2))");
PrincipalSearcher ps = new PrincipalSearcher(u);
PrincipalSearchResult<Principal> fr = ps.FindAll();
foreach (UserPrincipal usr in fr)
{
Response.Write(usr.DisplayName + " " +
usr.VoiceTelephoneNumber + "<br />");
}
I just wanted to see if someone can see something I am missing. This
code works, but does not seem to apply the filter. It pulls back all
the users whereas I am just looking for the ones that have name and
telephone populated and are not disabled. When I run this filter
directly inside the AD query tool I get the expected results. Just
doesn't seem to work right from my code. Thanks.
PrincipalContext ctx = new PrincipalContext(ContextType.Domain,
<Domain>,<UserName>,<Password>);
UserPrincipal u = new UserPrincipal(ctx);
u.AdvancedSearchFilter.Equals("(&(objectCategory=person)
(objectClass=user)(name=*)(telephoneNumber=*)(!userAccountControl:
1.2.840.113556.1.4.803:=2))");
PrincipalSearcher ps = new PrincipalSearcher(u);
PrincipalSearchResult<Principal> fr = ps.FindAll();
foreach (UserPrincipal usr in fr)
{
Response.Write(usr.DisplayName + " " +
usr.VoiceTelephoneNumber + "<br />");
}