Advertisement

02.19.2007 at 04:44AM PST, ID: 22398331
[x]
Attachment Details

VBScript error 0x80005000 - LDAP query

[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8
Tags:

ldap, vbscript, query, 0x80005000

hello Experts
Have a VBScript to query LDAP for names, nicks and SMTP addresses. It works just great dumping the contents to a file.
I have adapted it to load directly to a SQL Server db - but it stops after 222 records with the error 0x80005000 - there are about 10k recs to fetch!
The line it stops at is:
If instr(objUser.homemdb,"CN=") <> 0 then
and raises the error - please help! I have looked at all I can think of to find differences between the last record fetched and the following record it trips on - and can find only that the "surname" on the X500 entry is spelt wrongly....

Full routine below:

'On Error Resume Next
Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objRootDSE = GetObject("LDAP://rootDSE")
strDomain = "LDAP://"& objRootDSE.Get("defaultNamingContext")

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

objCommand.CommandText = "<"& strDomain &">;(objectCategory=person)" & _
";distinguishedName,cn;subtree"
objCommand.Properties("Page Size") = 40000

Set objRecordSet = objCommand.Execute

set objSQLConn = CreateObject("ADODB.Connection")
objSQLConn.Open = "Provider=sqloledb;Data Source=myServer;Initial Catalog=myDB;Integrated Security=SSPI;"
objSQLConn.Execute "TRUNCATE TABLE tmpAddresses"

set objRS2 = CreateObject("ADODB.Recordset")
objRS2.Open "SELECT * FROM tmpAddresses",objSQLConn, adOpenStatic, adLockOptimistic

While Not objRecordSet.EOF
strUserDN = objRecordSet.Fields("DistinguishedName")
set objUser = GetObject("LDAP://"& strUserDN)

If instr(objUser.homemdb,"CN=") <> 0 then              ' <--- ERROR raised on this line

For Each entry in objUser.GetEx("proxyAddresses")

If instr(entry,"X400") = 0 Then
proxy1 = replace(entry,"SMTP:","")

If instr(proxy1, "MBX:") = 0 Then
if instr(proxy1,"SMTP:") > 0 Then
if instr(objuser.mailnickname," ") = 0 then

objRS2.AddNew
objRS2.Fields("username").Value = objuser.mailnickname
objRS2.Fields("fullname").Value = objuser.displayname
objRS2.Fields("fname").Value = objuser.givenname
objRS2.Fields("sname").Value = objuser.sn
objRS2.Fields("proxyaddr").Value = proxy1
objRS2.Update

End If
End If
End If
end if
Next

End If

objRecordSet.MoveNext

Wend
objRS2.Close
objConnection.Close
objSQLConn.Close

Set objRootDSE = Nothing
set objRecordSet = Nothing
set objConnection = Nothing
set objCommand = Nothing
set objRS2 = Nothing
set objSQLConn = Nothing
set objUser = Nothing
set objOutputFile = Nothing
set objFSO = Nothing

wscript.Echo "All Done"
 
Accepted Solution by sirbounty:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Author Comment by gbshahaq:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Expert Comment by sirbounty:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Author Comment by gbshahaq:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Expert Comment by sirbounty:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Author Comment by gbshahaq:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
20081119-EE-VQP-46