You cannot use the distinguishedName attribute to sort an LDAP query in Windows 2000 or in Windows Server 2003 (842637)
The information in this article applies to:
- Microsoft Windows Server 2003, Standard Edition
- Microsoft Windows 2000 Server
SYMPTOMSWhen you try to use the distinguishedName attribute to sort the results of a Lightweight Directory Access Protocol (LDAP) query, you cannot successfully do so. However, when you perform this operation in Microsoft Windows 2000 Server, the specific symptoms are different from the symptoms that occur when you perform this operation in Microsoft Windows Server 2003. Windows 2000 Server returns no error, but it returns an unsorted result set. Windows Server 2003 returns an error code, but the result set is empty.WORKAROUNDTo sort on the distinguishedName attribute, perform the sort operation on the client side instead of on the server side, as in the following sample code: Const adUseClient = 3
Const adCmdText = 1
Const adSecureAuthentication = 1
Const adLockReadOnly = 1
Dim szQuery, g_oCon, g_oCmd, g_oRS
szQuery = "<LDAP://billtivpc01.ticehurst.com>;" + _
"(&(objectCategory=group)(&(distinguishedName=*)));" + _
"objectGUID, ou, distinguishedName;subtree"
Set g_oCon = CreateObject("ADODB.Connection")
Set g_oRS = CreateObject("ADODB.Recordset")
g_oCon.Provider = "ADsDSOObject"
g_oCon.Properties("Encrypt Password") = True
g_oCon.Properties("ADSI Flag") = adSecureAuthentication
g_oCon.Open "Active Directory Provider"
'*** The following server-side sort does not return any results.
'Set g_oCmd = CreateObject("ADODB.Command")
'Set g_oCmd.ActiveConnection = g_oCon
'g_oCmd.Properties("Sort On") = "distinguishedname"
'g_oCmd.CommandType = adCmdText
'g_oCmd.CommandText = szQuery
'g_oRS.Open g_oCmd, , adUseClient, adLockReadOnly
'*** Instead, the following client-side sort succeeds.
g_oRS.CursorLocation = adUseClient
g_oRS.Sort = "distinguishedname"
g_oRS.Open szQuery, g_oCon, , , adCmdText
While Not g_oRS.EOF
WScript.Echo g_oRS.Fields("distinguishedName").Value
g_oRS.MoveNext
Wend
WScript.Quit
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
Modification Type: | Major | Last Reviewed: | 6/25/2004 |
---|
Keywords: | kbprb KB842637 kbAudDeveloper |
---|
|