> Paloma wrote:
>
> > I am looking for a script which changes the postal address in all the
> > users
> > on my domain.
> > I've foung this one:
> > Set objUser = GetObject _
> > ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")
> >
> > objUser.Put "streetAddress", "Building 43" & _
> > VbCrLf & "One Microsoft way"
> > objUser.Put "l", "Redmond"
> > objUser.Put "st", "Washington"
> > objUser.Put "postalCode", "98503"
> > objUser.Put "c", "US"
> > objUser.Put "postOfficeBox", "2222"
> > objUser.SetInfo
> >
> > But it is only to change one postal address of a user. How can I do it for
> > all the users on my domain?
>
> Do you intend to give all users the same address? If so, you can use ADO to
> retrieve the Distinguished Names of all users, then in the loop where you
> enumerate the recordset, bind to each user, assign the attriubute values as
> above, and invoke SetInfo to save the changes. For information on using ADO
> in a VBScript program, see this link:
>
>
http://www.rlmueller.net/ADOSearchTips.htm>
> If everyone has their own address, you need a source for the information. I
> would suggest a spreadsheet. I have a sample VBScript program that modifies
> the profilePath property for users in bulk from the information in a
> spreadsheet linked here:
>
>
http://www.rlmueller.net/UpdateUserProfile.htm>
> The first column of the spreadsheet should have the Distinguished Name of
> the user, the second column has the value for profilePath. You could change
> this program to modify the attributes you want instead. Use more colunns of
> the spreadsheet. The reference objSheet.Cells(intRow, 2).Value refers to row
> intRow and column 2 of the spreadsheet.
>
> A quick program to give everyone the same address could be similar to below.
> Note this will modify all users, including Administrator and Guest.
> ==========================
> Option Explicit
>
> Dim adoCommand, adoConnection, strBase, strFilter, strAttributes
>
> Dim strQuery, adoRecordset, strDN, objUser
>
>
>
> ' Setup ADO objects.
>
> Set adoCommand = CreateObject("ADODB.Command")
> Set adoConnection = CreateObject("ADODB.Connection")
> adoConnection.Provider = "ADsDSOObject"
> adoConnection.Open "Active Directory Provider"
> adoCommand.ActiveConnection = adoConnection
>
>
>
> ' Search entire Active Directory domain.
> strBase = "<LDAP://dc=MyDomain,dc=com>"
>
>
> ' Filter on user objects.
> strFilter = "(&(objectCategory=person)(objectClass=user))"
>
>
>
> ' Comma delimited list of attribute values to retrieve.
> strAttributes = "distinguishedName"
>
>
>
> ' Construct the LDAP syntax query.
> strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
> adoCommand.CommandText = strQuery
> adoCommand.Properties("Page Size") = 100
> adoCommand.Properties("Timeout") = 30
> adoCommand.Properties("Cache Results") = False
>
>
>
> ' Run the query.
> Set adoRecordset = adoCommand.Execute
>
>
> ' Enumerate the resulting recordset.
> Do Until adoRecordset.EOF
>
> ' Retrieve values.
> strDN = adoRecordset.Fields("distinguishedName").Value
>
> ' Bind to user object.
>
> Set objUser = GetObject("LDAP://" & strDN)
>
> ' Modify attribute values.
>
> objUser.Put "streetAddress", "Building 43" & _
> VbCrLf & "One Microsoft way"
> objUser.Put "l", "Redmond"
> objUser.Put "st", "Washington"
> objUser.Put "postalCode", "98503"
> objUser.Put "c", "US"
> objUser.Put "postOfficeBox", "2222"
>
> ' Save changes.
> objUser.SetInfo
>
>
> adoRecordset.MoveNext
> Loop
>
>
>
> ' Clean up.
>
> adoRecordset.Close
>
> adoConnection.Close
>
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab -
http://www.rlmueller.net> --
>
>
>