Last post Sep 10, 2010 03:47 PM by deepak kumar .Govindarajan
Sep 09, 2010 11:45 AM|hiteshspatel|LINK
I am using Directory entry of System.Directoryservices class of Asp.net for authenticating against Sunone LDAP server. The following works fine.
DirectoryEntry entry = new DirectoryEntry("LDAP://SunOne2:42028/dc=domain,dc=com");
entry.AuthenticationType = AuthenticationTypes.None;
entry.Username = "uid=thost,ou=people,dc=domain,dc=com";(replaced original values)
entry.Password = password;
Now I want to be able to authenticate all the users of different organisation units. e.g. ou=development,ou=accounting etc., So I specified like this,
entry.Username = "uid=thost,ou=people,ou=devlopment,ou=accounting, dc=domain,dc=com";
but it says "There is no such object on the server". I also tried putting ou in URL. I am not sure where should I specify this OUs to make my search broad.
I found a lot on internet but no success so far. Could anybody please provide hint, suggestion or sample code.
Thanks for your time
asp net ldap directory services sunone
Sep 10, 2010 06:50 AM|johram|LINK
How can you know what organization they belong to when they log in? It seems to me you're approaching this problem the wrong way.
Wouldn't it be better if you do a site-wide search for the account, once you have it, you'll know the distinguished name and then you can authenticate that user?
Is there a unique constraint on the uid within SunOne? Or can there be more than one account with the same uid?
Sep 10, 2010 03:47 PM|deepak kumar .Govindarajan|LINK
Its very simple,
you can achieve through activeds.dll.this dll can be found in windows 2003 server System which has Active Directory Installed,just add as reference to your application.I struggled for this scenario...atlast i achieved that...
here is the code .
before that. you have to give the userid for this .ie.like userdID@example.com
this can be achieved through giving Principal Name:i.e like userdID@example.com
pass UserId as :userdID@example.com
public DirectoryEntry AuthenticateUsers(string UserName, string Password)
DirectoryEntry entry = null;
int lnSetType = 9;
int lnFormatType = 1;
NameTranslate translate = new NameTranslateClass();
string bstrADsPath = UserName;
//Here in Str2 u will recieve all the information.
string str2 = translate.Get(lnFormatType);
//Here in Str1 You have to give the domain ciontroller name
string str1 ="LDAP://172.16.2.5"
using (entry = new DirectoryEntry( + "/" + str2, new object), UserName, Password))
object nativeObject = entry.NativeObject;
//here put your logics....
catch (Exception exception)
Happy code...enjoy the day....
if you have problem,let me know:my email id;firstname.lastname@example.org...