Last post Mar 15, 2011 05:16 AM by jangtrektang
Mar 14, 2011 10:19 AM|jangtrektang|LINK
For my internship I have to create an application where people can login with their username & password from the active directory.
After reading a lot about LDAP and active directory on the internet and trying examples I just can't get it working.
What I've got so far is this:
public string connectLDAP()
using (DirectoryEntry rootDSE = new DirectoryEntry("LDAP://domain/RootDSE"))
rootDSE.Username = "***";
rootDSE.Password = "***";
defaultNamingContext = rootDSE.Properties["defaultNamingContext"].Value.ToString();
If I run this code and I show the defaultNamingContext in a label i get a return like: DC=domain,DC=local .But if I do
DirectoryEntry rootDSE = new DirectoryEntry("LDAP://domain/"+defaultNamingContext);
I get a error message that the connection bind is not succesfull. I don't get why this won't work because all the examples I can find on the internet do it like this.
Anyone know what I've gotta do to get this thing working, because I feel like I've tried allmost everything.
Mar 14, 2011 04:09 PM|smirnov|LINK
Try to change to LDAP://dc.domain.local/DC=domain,DC=local where dc.domain.local is DC Server Name. You can download free
LDAP Browser to browse your LDAP directory.
Mar 15, 2011 05:16 AM|jangtrektang|LINK
I found another solution, I used the DirectoryServices.AccountManagement class, here i just had to insert the domainname, and there is allready a authentication method present.