Re: Editing users UPN via script

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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@xxxxxxxxxxxx"
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
--


.



Relevant Pages

  • Re: Editing users UPN via script
    ... properties for those users in a script. ... NameTranslate object can convert the userPrincipalName to the Distinguished ... If the first value in your text file is the "Common Name" of the user, ... The Common Name must be unique in the container or OU, ...
    (microsoft.public.scripting.vbscript)
  • Re: Editing users UPN via script
    ... Let me know if you need any additional information on how to configure the script. ... NameTranslate object can convert the userPrincipalName to the Distinguished ... If the first value in your text file is the "Common Name" of the user, ... The Common Name must be unique in the container or OU, ...
    (microsoft.public.scripting.vbscript)
  • Re: rights issue perhaps ?
    ... container I have recently created it tells me that it cannot find ... In your script you specify the Common Name of the computer object. ... users will supply the NetBIOS name), then use the NameTranslate object to ...
    (microsoft.public.windows.server.active_directory)
  • Re: Moving Multiple users from many differnt OUs at once
    ... I ran the script for the Specify Common Name. ... ' Specify the NetBIOS name of the domain and the NT name of the user. ... ' Bind to the user object in Active Directory with the LDAP provider. ...
    (microsoft.public.windows.server.scripting)
  • Re: Looking for tutorial info on data structures
    ... > together container of pointers, indices, keys, module position ... > data structures for commonly encountered tasks, ... > pointers to a common reference container of data elements. ...
    (comp.unix.programmer)