esempio funzionante
codice:
<table>
<%
Security_Provider = "LDAP://NomeServerLocale_o_IP:389/DC=NomeDominio,DC=it"
Security_Principal = "CN=UtenteAbilitato,OU=Mail List and Accounts,OU=00 - Security Groups and Users,DC=NomeDominio,DC=it"
Security_Credentials = "PasswordUtenteAbilitato"
Dim rs
Dim oDS: Set oDS = GetObject("LDAP:")
Dim oAuth: Set oAuth = oDS.OpenDSObject(Security_Provider, Security_Principal, Security_Credentials, &H0200) ' ADS_SERVER_BIND
Dim oConn: Set oConn = CreateObject("ADODB.Connection")
oConn.Provider = "ADSDSOObject"
oConn.Open "Ads_Provider", Security_Principal, Security_Credentials
sUser = "*"
strQuery = "<" & Security_Provider & ">;(sAMAccountName=" & sUser & ");sAMAccountName,cn,mail,telephoneNumber,employeeID,mobile,facsimileTelephoneNumber;subtree"
Set oCommand = CreateObject("ADODB.Command")
oCommand.ActiveConnection = oConn
oCommand.Properties("Page Size") = 100
oCommand.Properties("Timeout") = 30
oCommand.Properties("Cache Results") = False
oCommand.CommandText = strQuery
Set rs = oCommand.Execute
n=0
do until rs.eof
n = n +1
mail = rs("mail").value : if isnull(mail) then mail=""
if mail="" then mail = rs("mail").value : if isnull(mail) then mail=""
telefono = rs("telephoneNumber").value : if isnull(telefono) then telefono=""
employeeID = rs("employeeID").value : if isnull(employeeID) then employeeID=""
cn = rs("cn").value : if isnull(cn) then cn=""
mobile = rs("mobile").value : if isnull(mobile) then mobile=""
fax = rs("facsimileTelephoneNumber").value : if isnull(fax) then fax=""
response.write "<tr><td align=right>"&n&"</td><td align=right>" & employeeID & "</td><td>" & cn & "</td>"
response.write "<td>" & telefono & "</td><td>" & fax & "</td><td>" & mobile & "</td>"
response.write "<td>" & mail & "</td></tr>" : response.flush
rs.movenext
loop
rs.close : set rs = Nothing
oConn.close : set oConn = Nothing
set oAuth = Nothing : set oDS = Nothing
%>
</table>
Ovviamente fondamentali sono i parametri di connessione... fatti aiutare dal Domain Administrator