<%
const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name,CN from 'LDAP://DC=nmc,DC=ln,DC=cmcc' " _
& "where objectClass='user' and Name='徐中'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Response.Write "Name: " & objRecordSet.Fields("Name").Value & "<br>"
Response.Write "CN: " & objRecordSet.Fields("CN").Value & "<br>"
objRecordSet.MoveNext
Loop
%>
整理中...
文章来源:http://ms.mblogger.cn/xuzhong/posts/16799.aspx