Scott Furr

Scott Furr

  • NA
  • 15
  • 0

Need to query against the IPPhone property

Jul 3 2012 10:52 AM
I'm trying to pull a list of users from Active Directory and I am succeeding, but I'm also pulling service accounts, which I do not want.  The distinguishing factor between a real user and a service account is the IPPhone property.  I found the PrincipalSearcher class but it doesn't contain the IPPhone Property.  Anyone know how to add it or query it in some other way?

My code is below.

static void Main(string[] args)
        {
            string groupName = "Domain Users";
            string domainName = "DOMAIN";

            PrincipalContext ctx = new PrincipalContext(ContextType.Domain, domainName);
            GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, groupName);
          
           
            if (grp != null)
            {
                foreach (Principal p in grp.GetMembers(false))
                {
                    Console.WriteLine(p.Name + " - " + p.DisplayName);
                
                }


                grp.Dispose();
                ctx.Dispose();
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("\nWe did not find that group in that domain, perhaps the group resides in a different domain?");
                Console.ReadLine();
            }
        }

Thanks in advance