"Glenn" <nospam@xxxxxx> wrote in message
news:u56ngdVGKHA.3708@xxxxxx
>I am trying to use the script below to read from an Access database and to
>update Active Directory. When I run it I get an error that "The server is
>not operational" Code 8007203A. It happens on the "Set obbUser = Get
>Object _ line.
>
> If I change the line below that, to ("LDAP://...") (filling in the "..."
> with the distinguished name of a given user, it works fine.
>
> Can someone please help me out with how to write the LDAP line?
>
> Thanks!
>
> ---script:
>
> Set objConnection = CreateObject("ADODB.Connection")
> Set objRecordSet = CreateObject("ADODB.Recordset")
>
> Const adOpenStatic = 3
> Const adLockOptimistic = 3
>
> objConnection.Open _
> "Provider = Microsoft.Jet.OLEDB.4.0; " & _
> "Data Source = \\myserver\myshare\users.mdb"
>
> objRecordSet.Open "SELECT * FROM QRY_STAFF" , _
> objConnection, adOpenStatic, adLockOptimistic
>
> objRecordSet.MoveFirst
>
> Do Until objRecordset.EOF
>
> Const ADS_PROPERTY_UPDATE = 2
>
> Set objUser = GetObject _
> ("LDAP:// & objRecordSet(""distinguishedName"") & ")
>
> objUser.Put "facsimileTelephoneNumber", "" &
> objRecordSet("facsimileTelephoneNumber") & ""
>
> objRecordset.MoveNext
> Loop
>
> objRecordSet.Close
> objConnection.Close I would try:
=========
Do Until objRecordset.EOF
Set objUser = GetObject _
("LDAP://" & objRecordSet.Fields("distinguishedName").Value)
objUser.Put "facsimileTelephoneNumber", _
objRecordSet.Fields("facsimileTelephoneNumber").Value
objUser.SetInfo
objRecordset.MoveNext
Loop
=========
An error will be raised if there is no value for facsimileTelephoneNumber,
so you might want to test for that. For example:
=======
Do Until objRecordset.EOF
strUserDN = objRecordSet.Fields("distinguishedName").Value
strFaxNumber = objRecordSet.Fields("facsimileTelephoneNumber").Value &
""
Set objUser = GetObject("LDAP://" & strUserDN)
If (strFaxNumber <> "") Then
objUser.Put "facsimileTelephoneNumber", strFaxNumber
objUser.SetInfo
End If
objRecordset.MoveNext
Loop
=========
I concatenate the blank string, "", to the fax number in case the value is
Null, so the variable is a blank string in that case. I don't do this for
distinguishedName, as it is required (or should be).
--
Richard Mueller
MVP Directory Services
Hilltop Lab -
http://www.rlmueller.net
--