Bei meinem Versuch eine Userliste aus dem Active Directory herauszulesen bin ich auf ein Problem gestossen, bei welchem ich eure Hilfe benötige.
Der ADsPath lässt sich Problemlos ausgeben.
Beim Ausgeben des CN erscheint jedoch eine Fehlermeldung:
Response object, ASP 0106 (0x80020005)
An unhandled data type was encountered.
Wie kann ich den CN ausgeben?
Code:
<%@language="vbscript"%>
<%
Option Explicit
Response.Expires = 0
Dim strQuery
Dim objUser
'---------------------------------------------
'Connection
'---------------------------------------------
Dim objRstMain, objConMain, objCmdMain
Set objRstMain = Server.CreateObject("ADODB.RecordSet")
Set objConMain = Server.CreateObject("ADODB.Connection")
Set objCmdMain = Server.CreateObject("ADODB.Command")
objConMain = "Provider=ADSDSOObject;User Id=PRIVATE\Administrator;Password=qwerASDF;Encrypt Password=False;Open=Active Directory Provider"
strQuery = "SELECT cn, ADsPath FROM 'LDAP://192.168.1.1/OU=Customers, DC=cust, DC=mydomain, DC=com' WHERE objectCategory='user'"
objCmdMain.ActiveConnection = objConMain
objCmdMain.CommandText = strQuery
%>
<html>
<head>
</head>
<body>
<table cellspacing="1" cellpadding="1" width="300" border="1" ID="Table1">
<%
Set objRstMain = objCmdMain.Execute
'Response.Write(objRstMain.RecordCount)
%>
<b>Anzahl Datensätze: </b>
<% =objRstMain.RecordCount %>
<br><br>
<%
Do While Not objRstMain.EOF
%>
<tr>
<td><% =objRstMain.Fields("cn").Value %></td>
<td><% =objRstMain.Fields("ADsPath").Value %></td>
</tr>
<%
objRstMain.MoveNext
Loop
objRstMain.Close
Set objRstMain = Nothing
Set objConMain = Nothing
Set objCmdMain = Nothing
%>
</table>
</body>
</html>