Click here to Skip to main content
15,908,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
public void check()
       {
           // Connect to LDAP
           AuthenticationTypes authTypes; // Authentication flags.
           authTypes = AuthenticationTypes.Signing | AuthenticationTypes.Sealing | AuthenticationTypes.Secure;
           string domainAndUsername = "xglobal" + @"\" + TextBox1.Text;
           DirectoryEntry oAuthedEntry = new DirectoryEntry();
           // Create new DirectorySearcher instance
           DirectorySearcher search = new DirectorySearcher(oAuthedEntry);
           // Set search criteria
           search.Filter = "(objectCategory=user)";
           //search.PropertiesToLoad.Add("displayName");                             // name
           //search.PropertiesToLoad.Add("physicalDeliveryOfficeName");      // location
           search.PropertiesToLoad.Add("telephoneNumber");                    // phone number
           search.PropertiesToLoad.Add("mobile");                                     // mobile
           //search.PropertiesToLoad.Add("mail");                                        // email address
           //search.PropertiesToLoad.Add("msDS-UserAccountDisabled");   // account status
           //search.PropertiesToLoad.Add("title");                                        // title
           //search.PropertiesToLoad.Add("ms-DS-UserAccountAutoLocked");     // locked
           search.Filter = String.Format("(SAMAccountName={0})", TextBox1.Text);
           // Perform the search
           SearchResultCollection results = null;
           try
           {
               results = search.FindAll();
               Response.Write(results .ToString());

I Am Stuck Here
:confused:
}
          catch (Exception searchEx)
          {
              throw new Exception("Error obtaining users results. ", searchEx);
          }

      }




If i retrive the count of the results collection , it says 1;
but i am not sure if its the result or not.
Posted

1 solution

HI
check the link to get Telephone Numbers using LDAP Querying Active Directory using .NET classes and LDAP queries[^]

Just modified the code to get "Telephone Number" instead of "Name"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900