Hi..
How to get Phone Number, Email Id from Active Directory which is present in Network..
Send Some Sample working Code as an attachment
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
mahendra bisht9 reputationPosted Sep 1, 2013, 8:46 AM EDT
DirectoryEntry dirEntry = new DirectoryEntry();
dirEntry .Path = ConfigurationManager.AppSettings[AD_SERVER] + ConfigurationManager.AppSettings[AD_DOMAIN_NAME];
dirEntry .Username = ConfigurationManager.AppSettings[AD_ADMIN_USER];
dirEntry .Password = ConfigurationManager.AppSettings[AD_ADMIN_PASSWORD];
dirEntry .AuthenticationType = AuthenticationTypes.Secure;
//create instance fo the direcory searcher
DirectorySearcher dirSearch = new DirectorySearcher(dirEntry);
dirSearch.SearchRoot = dirEntry;
//set the search filter
dirSearch.Filter = "(&(objectClass=user)(cn=" + UserName + "))";
//find the first instance
SearchResult searchResults = dirSearch.FindOne();
//if found then return, otherwise return Null
if ((searchResults != null))
{
//if so then return the DirectoryEntry object
DirectoryEntry user = searchResults.GetDirectoryEntry();
}
string mail=user.Properties[MAIL].Value
mahendra bisht9 reputationPosted Sep 1, 2013, 8:47 AM EDT
DirectoryEntry dirEntry = new DirectoryEntry();
dirEntry .Path = ConfigurationManager.AppSettings[AD_SERVER] + ConfigurationManager.AppSettings[AD_DOMAIN_NAME];
dirEntry .Username = ConfigurationManager.AppSettings[AD_ADMIN_USER];
dirEntry .Password = ConfigurationManager.AppSettings[AD_ADMIN_PASSWORD];
dirEntry .AuthenticationType = AuthenticationTypes.Secure;
//create instance fo the direcory searcher
DirectorySearcher dirSearch = new DirectorySearcher(dirEntry);
dirSearch.SearchRoot = dirEntry;
//set the search filter
dirSearch.Filter = "(&(objectClass=user)(cn=" + UserName + "))";
//find the first instance
SearchResult searchResults = dirSearch.FindOne();
//if found then return, otherwise return Null
if ((searchResults != null))
{
//if so then return the DirectoryEntry object
DirectoryEntry user = searchResults.GetDirectoryEntry();
}
string mail=user.Properties["mail"].Value