Home » Bulk AD Users - Bulk AD Users - Bugs » Strange issue with AD Update Script Messages in this topic - RSS
|
8/25/2011 5:58:17 PM
jsirken
jsirken
Posts 1
Using information picked up here, I created a script which will update our Active Directory with information from an external system. I'm testing this with an Access 2010 database linked to SQL tables.

The code below compiles, but gives an unspecified error when running. In this example, my source table has a value for "newAttribute" of 444444, and the value for strAdsPath is a long (but accurate) string containing the LDAP DN.

When debugging this, if I put a breakpoint on the line:
objUser.put "employeeID", NewAttribute
I can see that strAdsPath has a proper value, and that NewAttribute shows "444444" as a value.

When continuing past that, I get the famous "Run-time error '-2137467259(80004005)'; Automation error Unspecified error.

If it change that line of code to manually type the value instead of using NewAttribute, this works and updates AD fine. So, the above line would read:
objUser.put "employeeID", 444444
*I've tried testing this variable as a String and Long, with and without quotes - it seems that isn't the problem.

Any assistance you can offer would be greatly appreciated. Here's the function:
Public Function UpdateEmployeeID()
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim strAdsPath As String
Dim NewAttribute As String

Set Db = CurrentDb
Set Rs = Db.OpenRecordset("UpdateEmpId", dbOpenDynaset)

Rs.MoveLast
Rs.MoveFirst

Do While Not Rs.EOF
strAdsPath = Rs!strAdsPath.Value
NewAttribute = Rs!NewAttribute.Value
Dim objUser
'<<<< Bind to the user object using the distinguished name >>>>
Set objUser = GetObject(strAdsPath)

'<<<< Set the property >>>>

objUser.put "employeeID", 444444

objUser.setinfo 'Save Changes
Rs.MoveNext
Loop

Rs.Close
Set Rs = Nothing
Db.Close
Set Db = Nothing

End Function


, and will update Active Directory from my sample data:
9/2/2011 11:20:39 AM
admin
admin
Posts 331
Hi,

I've tested the following and it works ok:

set objUser=GETOBJECT("LDAP://cn=test123,cn=users,dc=wisesoft,dc=co,dc=uk")
objUser.put "employeeID", 444444
objUser.SetInfo

The employeeID attribute is actually a string, but it doesn't seem to make a difference. I would check that your strADsPath value is correct.

Hope this helps,

David
pages: 1
|

Home » Bulk AD Users - Bulk AD Users - Bugs » Strange issue with AD Update Script