Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching LDAP using ADSI from ASP (vbscript)

Status
Not open for further replies.

jaygreen4

Technical User
Feb 13, 2006
4
GB
Hi,
I have a problem in that I have some old asp/vbscript code (pre .NET) running on a Win2000 server that I need to update. The code authenticates a login (from a form) using our ldap server. We are moving ldap servers and the structure has changed. Previously all the users were in the same place so we could set the root directory but now they could be in a number of places down the tree.

To be able to authenticate the user I need to search ldap to find the users location in the tree before I can then go back and authenticate using the correct root directory. Has anyone managed to do this ? (I've spent hours on google with no luck).

This is how the code currently works (UserIdReq and PasswordReq are passed in from a form) :

Const cLDAPServer = "LDAP://ldap.mydomain:389/"
cNameString = "ou=staff,ou=accounts,dc=uea,dc=ac,dc=uk"

strNameString = cNameString
strADsPath = cLDAPServer + strNameString
strUserName = "cn=" + UserIdReq + "," + strNameString
strADsNamespace = left(strADsPath, instr(strADsPath, ":"))

set oADsNamespace = GetObject(strADsNamespace)
set oADsObject = oADsNamespace.OpenDSObject(strADsPath, strUserName, PasswordReq, 0)

' we've only managed to bind if err.number = 0
if not (Err.number = 0) then
ValidateLDAPUser = true
else
ValidateLDAPUser = False
end if

any pointers would be great as I'm really stuck.

Thanks,

Jay.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top