Bonjour à tous!
J'ai un petit souci avec une application en ASP dont le but est de créer un répertoire téléphonique basé sur l'Active Directory.
J'ai écrit un code, sur la base d'exemples trouvés sur le net, mais qui m'affiche un message d'erreur dont je ne comprends pas l'origine.
<%@ LANGUAGE=VBSCRIPT %>
<%Option Explicit%>
<%
Sub getUserData()
on error resume next
set rsUserData = Server.CreateObject("ADODB.Recordset")
strGeneralLookupError = false
strBase = "< LDAP://DC=[DOMAIN],DC=[DOMAIN_EXT ]>"
strFilter = "(sAMAccountName="*")"
strAttributes = "cn, mail, company, givenName, sn, ADsPath, name, sAMAccountName, telephoneNumber"
strScope = "subtree"
strFullCommand = strBase & ";" & strFilter & ";" & strAttributes & ";" & strScope
set rsUserData = connAD.Execute(strFullCommand)
if err.number <> 0 then
strGeneralLookupError = true
end if
if not rsUserData.EOF then
strUserGN = rsUserData("givenName")
strUserSN = rsUserData("sn")
strUserPhone = rsUserData("telephoneNumber")
else
strADLookupSuccess = false
end if
rsUserData.Close
set rsUserData = Nothing
End Sub
on error resume next
response.expires = 0
DIM connAD, rsUserData, rsADUserInfo
DIM strUserGN, strUserSN, strUserPhone
DIM strBase, strFilter,strAttributes, strScope, strFullCommand
DIM strGeneralLookupError, strADLookupSuccess
DIM strUserID
strUserGN = "The user can not be found in the system."
strGeneralLookupError = false
strADLookupSuccess = true
set connAD = Server.CreateObject("ADODB.Connection")
connAD.Provider = "ADsDSOObject"
connAD.Properties("User ID") = "[DOMAIN]\[DOMAIN_ADMIN]" ' ### remember to make sure this user has rights to access AD
connAD.Properties("Password") = "[DOMAIN_PASSWORD]"
connAD.Properties("Encrypt Password") = true
connAD.Open
call getUserData()
connAD.Close
set connAD = Nothing
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>[DOMAIN] PHONEBOOK</title>
</head>
<body>
<%=strUserGN%> <%=strUserSN%> <%=strUserPhone%><br />
</body>
</html>
Le message d'erreur est le suivant:
The user can not be found in the system.
En l'occurrence, j'utilise une wold card (*) afin de lister tous les utilisateurs..
Merci d'avance de votre aide.