Hi Guys, Thanks for visiting our blog . In this Post , We are going to get User data from Active Directory in C# . We can also use the code in SharePoint also as per the requirement. Please find the code for getting user details from AD (Active directory ). Before writing the code We need to get System.DirectoryServices dll from assembiles. into the page.
protected void btnSubmit_Click(object sender, EventArgs e) { try { string connection = "LDAP:// server name"; // LDAP Server Name DirectorySearcher dssearch = new DirectorySearcher(connection); dssearch.Filter = "(sAMAccountName=" + txtusername.Text + ")"; // Passing UserName SearchResult sresult = dssearch.FindOne(); DirectoryEntry dsresult = sresult.GetDirectoryEntry(); // retrieving data string FirstName = dsresult.Properties["givenName"][0].ToString(); string LastName = dsresult.Properties["sn"][0].ToString(); string EmailID = dsresult.Properties["mail"][0].ToString(); } catch (Exception ex) { //Exception Handling } }
Related Post
SharePoint
- Build Automation (CICD) of WebJob in SharePoint Online
- List view render using JSLink with Fabric UI
- Delete Quick Links using Powershell
- SharePoint Interview Questions and Answers..
- Issues:SharePoint Foundation 2013 Prerequisites installation(off line) on Windows Server2012 R2
- SharePoint Column Field Types
- Alternate to InfoPath Forms in SharePoint
- Get the Items inside the Folder in document Library in SharePoint 2013 using REST API
- SharePoint 2016 [Beta] Release Date
- SharePoint Modal Dailoge to Open Page
- What is Look up Column and how to use in SharePoint 2010,2013
- People Picker Check User Entry and Resolve
- History of SHAREpoINt
- How to Create Application Page in SharePoint using Visual Studio 2010,2013
- Retrieve Site Features in SharePoint
- Weather Webpart by using Yahoo Service in Share Point
- Activate Telnet Client in Windows Server
- Navigate to another Page After Clicking on JavaScript Alert
- How to read List Item Version Collection Programmatically
- How to get Worker Process from Command Prompt
- How to Use DataTable.js in SharePoint webpart
- Adding New Link to PromotedActions Delegate Control in SharePoint 2013
- How to Deploy Master Page in Share Point
- Get Role Definition in SharePoint
Active Directory
0 comments:
Post a Comment