Wiseman82
Wed Mar 12 03:34:25 CDT 2008
I wrote a generic script to update user attributes from a CSV file:
http://www.wisesoft.co.uk/Scripts/display_script.aspx?id=178
Let me know if you need any additional information on how to configure the
script.
Hope this helps,
David
"Angela" <Angela@discussions.microsoft.com> wrote in message
news:162C6A16-37C1-4507-9B99-EE6C3D87FD20@microsoft.com...
> Thanks to all; the fuzzy image in my sight is gradually getting focused...
> It's on the "Account" tab, "User login name" field, and yes all the
> objects
> reside in the "cn=Users" container. Does that help you to help me?
>
> "Richard Mueller [MVP]" wrote:
>
>> Angela wrote:
>>
>> >I have a text file called C:\Temp\USERS.TXT (which the format can be
>> >changed
>> > if needed), that has the following (UserLogonName, UPN format):
>> >
>> > User1, @mydomain.com
>> > User2, @mydomain.com
>> > User3, @mydomain.com
>> > User4, @mydomain.com
>> > User5, @mydomain.com
>> > User6, @mydomain.com
>> >
>> > I want to be able to change the UPN listing (in some cases it's not
>> > present
>> > at all for users) that appears next to the "User logon name" on the
>> > Account
>> > properties for those users in a script. I can edit a script to change
>> > this
>> > for a user but in this case I want to be able to read in the
>> > information
>> > from
>> > a file, can this be done editing this script? Or do I have to do it
>> > manually?
>> >
>> >
>> > Set objUser = GetObject _
>> > ("LDAP://cn=User1,dc=NA,dc=mydomain,dc=com")
>> >
>> > objUser.Put "userPrincipalName", "MyerKen@fabrikam.com"
>> > objUser.Put "sAMAccountName", "MyerKen01"
>> > objUser.Put "userWorkstations","wks1,wks2,wks3"
>> > objUser.SetInfo
>>
>> Your text file has two values per line, delimited with a comma. If the
>> first
>> value is the NT name of the user (the "pre-Windows 2000 logon name"), you
>> can use the NameTranslate object to convert to the Distinguished Name (as
>> indicated by Anthony Houssa). However, if the first value is the "User
>> logon
>> name" shown on the "Profile" tab of the user properties dialog in ADUC,
>> then
>> we have a problem. This attribute is not required to have a value, and
>> you
>> indicate that some of your users do not have a value assigned. This is
>> the
>> value of the userPrincipalName attribute of the user object. The
>> NameTranslate object can convert the userPrincipalName to the
>> Distinguished
>> Name, but only if there is a value, and the value uniquely identifies the
>> object in AD.
>>
>> If the first value in your text file is the "Common Name" of the user,
>> this
>> is the value of the cn attribute. This does not uniquely identify the
>> user
>> in AD. The Common Name must be unique in the container or OU, but there
>> can
>> be several users in the domain with same Common Name. If you know that
>> the
>> values of the cn attribute are unique, and you know that all users are in
>> the same container or OU, you can use code similar to your example.
>> However,
>> note in your example that you assume the user is in the root of the
>> domain,
>> not in any container or OU. Is this really true?
>>
>> We need to know if the first value on each line of the file is the:
>>
>> 1. NT name of the user, also called the "pre-Windows 2000 logon name" (on
>> the "Profile" tab of ADUC), which is the value of the sAMAccountName
>> attribute.
>> 2. The Common Name of the user, which is the value of the cn attribute.
>> 3. The "User logon name" on the "Profile" tab of ADUC, which is the value
>> of
>> the userPrincipalName (with the @mydomain.com appended).
>>
>> If the value is 2 (Common Name), we need to either know where in AD all
>> the
>> objects reside (perhaps in the "cn=Users" container), or we need to know
>> that the values uniquely identify the users, so we can use ADO to search
>> AD
>> for the users. If the value is 2 (userPrincipalName), we can only modify
>> users that don't need modification because they already have the correct
>> value assigned. We need some way to identify (find) the user in Active
>> Directory.
>>
>> --
>> Richard Mueller
>> Microsoft MVP Scripting and ADSI
>> Hilltop Lab -
http://www.rlmueller.net
>> --
>>
>>
>>