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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
mahendra bishtPosted Sep 1, 2013, 12:47 PM
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 bishtPosted Sep 1, 2013, 12:46 PM
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