Posts

Showing posts with the label Active Directory Services

how to retrieve data from active directory using c#

how to retrieve data from active directory using c#: step 1: First include this namespace  using System.DirectoryServices; step 2: And in page load function use the following code (Use your active directory domain name,username,password in the following code)   protected void Page_Load(object sender, EventArgs e)         {             string domainname = "mydomain" ; string username = "admin" ; string password = "1234" ;             DirectoryEntry entry = new DirectoryEntry ( "LDAP://" + domainname, username, password,    AuthenticationTypes .Secure);             DirectorySearcher search = new DirectorySearcher (entry);             search.Filter = "(SAMAccountName=" + username + ")" ; //Thi...