Quantcast
Channel: Directory Services forum
Viewing all articles
Browse latest Browse all 31638

LDAP Automation error automation error -2147463155 8000500d trying to update AD from Excel VBA

$
0
0

AD on Win 2012 R2

I'm working in an isolated sandbox with a test AD server and a Win 7 workstation running Office 2013. I am new to AD and LDAP, but quite proficient in VB and VBA (and C# for that matter).

The automation error I get might have to do with an invalid LDAP reference. That's all I could dig up.
automation error -2147463155 8000500d

The overall objective is to update Active Directory fields using rows of user data in an Excel spreadsheet and VBA. I loop through each Excel Row and get the email address, and then I do a query through ADODB to get the ADsPath of a user with an AD query using email address which is unique:

Set conn = new ADODB.Connection conn.Provider = "ADsDSOObject" conn.Open "Active Directory Provider" Set cmd = New ADODB.Command Set cmd.ActiveConnection = conn cmd.Properties("Page Size") = 1000 cmd.Properties("Timeout") = 30 cmd.Properties("Cache Results") = False cmd.Properties("Chase Referrals") = &H20 Or &H40 cmd.CommandText = "LDAP://DC=mydc1, DC=mydc2,>;(&(objectCategory=person) (objectClass=user) (mail=" & srcEmail & "));ADsPath;subtree" Set rs = cmd.Execute If rs.BOF and rs.EOF Then ' no AD record returned, so write out an error in the spreadsheet wsData.Cells (i, STATUS_COL) = NOTFOUND_ERR Else rs.MoveFirst userDN = rs.Fields(0).Value Set thisUser = GetObject(userDN)

' so far so good, the userDN was returned as follows, and the GetObject function threw no errors: 'LDAP://CN=mylastname\, Bill, OU=Users,OU=Information Services,OU=Finance,DC=mydc1,DC=mydc2'

' Now comes the problem thisUser.Put "Employee-Number", wsData.Cells(i, SRC_EMPLOYEEID_COL) '<<< This throws the automation error ' I tried to use a Get just to see if maybe I was able to do a read, but not a write, but it didn't work either adEmail = thisUser.Get("email") '<<< This also throws the same automation error ' ' ' thisUser.SetInfo '<<< I never make it to here

I am at a loss given the fact that the query to return the AdsPath works fine, but it seems the path it returns is invalid.

Thanks in advance for your help.

Bill



Viewing all articles
Browse latest Browse all 31638


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>