Search user in win2003 AD by samaccountname
Posted on 2005-04-17
To whom it may concerned:
My question is about windows 2003 Active Directory.
Now I need to write a program for users to change their AD password using ASP(Active Server Page).
Since we display users' Chinese name in AD, For example, the distinguishname of ldap is : CN=黃黃,OU=MIS,OU=BioIT,DC=ngc,DC=sinica
and the samaccountname is : cccc
User only know their samaccountname, but the program need the find user by distinguishname.
How can I deal with this problem?
Here is some of my code:
Set RootDSE = GetObject("LDAP://RootDSE")
DomainContainer = RootDSE.Get("DefaultNamingContext")
Set UsrObj = GetObject("LDAP://CN=" & UserName & "," & SubContainer & "," & DomainContainer & "")
I would like to know :
Are there any solution that this line
Set UsrObj = GetObject("LDAP://CN=" & UserName & "," & SubContainer & "," & DomainContainer & "") search by users' samaccountname?
Because user only know their samaccountname, and it is different from UserName(var).
Are there any solution that you can give me?
Thank you so much!! ^^