USER NAME + Mobile in AD  
Author Message
Hussain Saffar

PostPosted: .NET Base Class Library, USER NAME + Mobile in AD Top

how to get all users name plus his/her mobile number

.NET Development25  

PostPosted: .NET Base Class Library, USER NAME + Mobile in AD Top

this can be done using the ActiveDirectory namespace(s) in .NET 2.0

Now I don't have a domain so I can't really test this but hopefully we can work together on this. It's basically finding the user name and read their properties. Remember to add the System.DirectoryServices and System.DirectoryServices.ActiveDirectory in the using statement to import the namespace


private void GetProperty(string loginName, string propertyName)
          DirectoryEntry theDirectoryEntry = new DirectoryEntry("LDAP://OU=Domain,DC=YourDomain,DC=com");

          theDirectoryEntry.AuthenticationType = AuthenticationTypes.Secure
          DirectorySearcher theSearcher = new DirectorySearcher(theDirectoryEntry);
          //string theFilter = propertyName;


          theSearcher.Filter = theFilter;
          SearchResult theResult = theSearcher.FindOne();

          if (theResult == null) 
               throw new NullReferenceException("No such directory entry exists");

          DirectoryEntry directoryObject = theResult.GetDirectoryEntry();


so basically you all it, give it the loginName (try domain\username format) and give it the "mobile" as a propertyName, hopefully something will come out of it.

Does this help/give you some guidence