Wednesday, August 11, 2010

ASP LDAP authentication and retrieve details

strUser = "xxx"

strDN = "cn=" & sUser & ",ou=people,dc=company,dc=com"
strRoot = "LDAP://servername.com/dc=company,dc=com"
Dim objDS: Set objDS= GetObject("LDAP:")
Dim objAuth: Set objAuth = objDS.OpenDSObject(strRoot , strDN , "password", &H0200)
Dim objConn: Set objConn= CreateObject("ADODB.Connection")
objConn.Provider = "ADSDSOObject"
objConn.Open "Ads Provider", strDN , "password"

Dim rs
Set rs = oConn.Execute("<" & sRoot & ">;(uid=" & strUser & ");cn,mail,telephoneNumber;subtree")
Response.write rs("cn").value
Response.write rs("mail").value
Response.write rs("telephoneNumber").value
rs.Close

objConn.Close
Set objConn = nothing
...

No comments:

Related Posts Plugin for WordPress, Blogger...