#63631 - 2002-03-07 03:45 PM
Renaming Accounts
|
rc10t
Fresh Scripter
Registered: 2002-01-24
Posts: 20
|
We are starting a project to rename around 1500 users login name. This is on a NT4 domain. Is there a way for kix to read a .txt file or any other file and see old name and new name and change it? I have seen it done with single users, but need to do multiple users at one time.
Thanks.
|
|
Top
|
|
|
|
#63632 - 2002-03-07 04:26 PM
Re: Renaming Accounts
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
here is something to work off of...
you will need this UDF UserRename() and the security rights to make these changes.
the userfile looks something like this.
code:
;old name,new name ;you may use ; to comment out lines in this file.
mroot2,Mroot james2,james testuser2,testuser
here is the kix code.
code:
$usersfile = "users.txt"
$nul = open(1,$usersfile,2)
$userdata = readline(1) do select case substr($userdata,1,1) = ";" or instr($userdata,",") = 0 ;ignore this line case 1 $userdata = split($userdata,",")
if ubound($userdata) <> 1 ? "Please check the $userfile for bad data" exit(1) endif $error = userrename(@domain,$userdata[0],$userdata[1])
if @error = 0 ? "User " + $userdata[0] + " Renamed to " + $userdata[1] color g+/n " OK" color w/n else ? color r+/n "ERROR RENAMING " + $userdata[0] + " TO " + $userdata[1] + " @error:@serror" color w/n endif
endselect $userdata = readline(1) until @error <> 0
Bryce [ 07 March 2002, 16:30: Message edited by: Bryce ]
|
|
Top
|
|
|
|
#63634 - 2002-03-07 04:38 PM
Re: Renaming Accounts
|
rc10t
Fresh Scripter
Registered: 2002-01-24
Posts: 20
|
Thanks Bryce, I'll give it a try.
|
|
Top
|
|
|
|
#63635 - 2002-03-07 05:58 PM
Re: Renaming Accounts
|
rc10t
Fresh Scripter
Registered: 2002-01-24
Posts: 20
|
I get a "1:COM exception error..." Any thoughts?
|
|
Top
|
|
|
|
#63637 - 2002-03-07 08:18 PM
Re: Renaming Accounts
|
rc10t
Fresh Scripter
Registered: 2002-01-24
Posts: 20
|
Duh...I forgot all about that. Thanks to both of you.
|
|
Top
|
|
|
|
#63638 - 2002-03-07 09:07 PM
Re: Renaming Accounts
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
Thanks Shawn! I have come to feel like we have always had ADSI
rc10t, If i may ask...
what are you renaming to? I am guessing that you are wanting to implement a user id naming convention like first initial plus first 7 letters of the last name.
I am also guessing that your current naming convention is all over the map....for three Bill Smiths you have a smith, smithb, bsmith....
with some feedback, a script that does not need a txt file might be able to be created.
Bryce [ 07 March 2002, 21:09: Message edited by: Bryce ]
|
|
Top
|
|
|
|
#63639 - 2002-03-07 09:19 PM
Re: Renaming Accounts
|
rc10t
Fresh Scripter
Registered: 2002-01-24
Posts: 20
|
Actually we currently use a first initial next seven of last name. If there is a duplicate then middle i is used. But the company is consolidating domains, so everyones id will become their employee number. What a mess if you ask me. Is there a way to change the profile path id exist to the new id as well? We use roaming profiles for our Terminal Server users. And also do a home folder rename?
|
|
Top
|
|
|
|
#63640 - 2002-03-07 10:30 PM
Re: Renaming Accounts
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
yes, both of these settings can be changed via ADSI.
here is some code...
code:
$userdata = split("mroot,Mroot",",") $profile = "new profile" $homedirectory = "new home directory"
$UserOBJ = GetObject("WinNT://@domain/"+$userdata[1]+",user") if vartype($UserOBJ) = 9 and @error = 0
;here is the profile $userobj.put("Profile","$profile") if @error = 0 $userobj.SetInfo else ? "Error setting profile" endif
;here is the HomeDirectory $userobj.put("HomeDirectory","$homedirectory") if @error = 0 $userobj.SetInfo else ? "Error setting homedirectory" endif
endif
Bryce
|
|
Top
|
|
|
|
#63641 - 2002-03-28 09:49 PM
Re: Renaming Accounts
|
Anonymous
Anonymous
Unregistered
|
FYI ... You can redirect Windows 2000 to your old profile by editing the registry. Open the Registry Editor and then open the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList. Under this branch, locate the key that contains your profile settings. The easiest way to identify the correct key is to check the value of ProfileImagePath in the key and locate the one pointing to your current profile directory. Then, edit the value of ProfileImagePath to point to the old profile path. Log off and log back on; this should restore your original profile.
|
|
Top
|
|
|
|
#63642 - 2002-04-10 06:23 PM
Re: Renaming Accounts
|
rc10t
Fresh Scripter
Registered: 2002-01-24
Posts: 20
|
How can you get this to report errors to a log file using the rename udf?
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 836 anonymous users online.
|
|
|