Richard
Tue Sep 16 17:32:30 CDT 2003
Eimis wrote:
> I have 150 users under single ou=employees, I need to configure a script
so
> that it would configure addresses for the users. Here is what I got so
far:
>
> Const ADS_PROPERTY_UPDATE = 2
> Set objUser = GetObject _
> ("LDAP://cn=whatever,ou=employees,dc=test,dc=org")
>
> objUser.Put "streetAddress", "999 test st"
> objUser.Put "l", "Boston"
> objUser.Put "st", "MA"
> objUser.Put "postalCode", "11111"
> objUser.Put "c", "US"
>
> objUser.PutEx ADS_PROPERTY_UPDATE, _
> "postOfficeBox", Array
>
> objUser.SetInfo
>
>
> But this only does for single user, I don't want to go to 150 users
> properties and update manually or retype the script user name everytime.
Hi,
If everyone has the same address, you could just bind to the OU, enumerate
the users, and assign the attributes:
Const ADS_PROPERTY_UPDATE = 2
Set objOU = GetObject("LDAP://ou=employees,dc=MyDomain,dc=com")
objOU.Filter = Array("user")
For Each objUser In objOU
objUser.Put "streetAddress", "999 test st"
objUser.Put "l", "Boston"
objUser.Put "st", "MA"
objUser.Put "postalCode", "11111"
objUser.Put "c", "US"
objUser.PutEx ADS_PROPERTY_UPUDATE, "postOfficeBox", Array("4012")
objUser.SetInfo
Next
Most likely, however, everyone has a different address. In that case I would
prepare a spreadsheet with the information required to update the users. The
program linked below demonstrates how to update users from the info in a
Microsoft Excel spreadsheet:
http://www.rlmueller.net/Read%20from%20Excel.htm
The program reads the Distinguished Name (DN) of users in the first column.
The first row is skipped (column headings) and a user is processed for each
subsequent row, until a blank row is encountered. The values for other
attributes are in the other columns. The program binds to each user object
in turn, assigns the attributes, then invokes SetInfo. You have to modify
the program to update your attributes rather than the ones used in this
example.
To create a spreadsheet of user Distinguished Names, you could modify this
example VBScript program:
http://www.rlmueller.net/Create%20User%20List%203.htm
As written it outputs all users in the domain. To modify the program to just
output the DN's of users in your one OU, you would replace this statement in
the program:
strQuery = "<LDAP://" & strDNSDomain & ">;" & strFilter _
& ";distinguishedName;subtree"
with this one:
strQuery = "<LDAP://ou=employees," & strDNSDomain & ">;" & strFilter _
& ";distinguishedName;oneLevel"
You would then have to add the address values in the other columns. I hope
this helps.
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site -
http://www.rlmueller.net
--