Batch Creation of AD Accounts Win 2000 Server

  • Thread starter Thread starter Steve Geho
  • Start date Start date
S

Steve Geho

Does anyone know of a tool to batch create AD accounts?
We need to quickly re-establish a set (600) accounts in
relatively simple Win 2000 server domain. Thanks for
your input.
 
Set objRootDSE = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://cn=Users," & _
objRootDSE.Get
("defaultNamingContext"))

For i = 1 To 600
Set objLeaf = objContainer.Create("User", "cn=UserNo"
& i)
objLeaf.Put "sAMAccountName", "UserNo" & i
objLeaf.SetInfo
Next
WScript.Echo "1000 Users created."


******************************************
 
Does anyone know of a tool to batch create AD accounts?
We need to quickly re-establish a set (600) accounts in
relatively simple Win 2000 server domain. Thanks for
your input.
Here is a PERL script I wrote to assist with account creation. It will take a bit of work to have it
meet your needs but it can also give you ideas for other ways to do the job.

--
Mike Miller
If all else fails - READ THE INSTRUCTIONS!
or if you like
"If all else fails - THROW HARDER" Robert Smith(pro bowler)


#!/h/AFDI/bin/perl
#this script creates a VBS script to add a user to the Windows domain.
#all input comes from the Helpdesk Access Form when the Add User to Helpdesk
#button is clicked
#
#Mike Miller 7 Jan 2003
#Updated 29 May 2003 so that it works on both platforms.


my($OS, $username, $userPrincipalName, $displayName, $access_H, $access_G,
$givenName, $initials, $sn, $telephoneNumber, $Office_OU, $Command_OU, $accesses);


#all args are passed in via @ARGV. extract them and insert into named vars
#to make reading this easier.
#input format is:
# OS username givenName initials surname(sn) Command Office telephoneNumber access_H access_G
$OS = shift(@ARGV);
$username = shift(@ARGV);
$givenName = shift(@ARGV);
$initials = shift(@ARGV);
$sn = shift(@ARGV);
$Command_OU = shift(@ARGV);
if ($Command_OU eq "USTC") {
$Command_OU = "J2";
}
$Office_OU = shift(@ARGV);
$telephoneNumber = shift(@ARGV);
$access_H = shift(@ARGV);
$access_G = shift(@ARGV);
$accesses = "["; #set the first character
if ($access_H == 1) {
$accesses = $accesses . " H";
}
if ($access_G == 1) {
$accesses = $accesses . " G";
}
if (length $accesses > 1){
$accesses = $accesses ." ]";
}
else {
$accesses = "";
}
$userPrincipalName = "$username\@ds.transcom.ic.gov"; # gen default mail host data in case not there
already
$displayName = "$sn, $givenName";
if ($OS =~ /Windows/) {
$W2KUSERSfile = "I:\\WindowsStuff\\User_Adds_Windows\\$username.vbs";
} else {
$W2KUSERSfile = "/COMMON/WindowsStuff/User_Adds_Windows/$username.vbs";
}
open(W2KUSERS,"> $W2KUSERSfile" ) || die "Can't open $W2KUSERSfile: $!\n" ;
print(W2KUSERS "Set UsrObj = GetObject\(\"LDAP://OU=$Office_OU,OU=$Command_OU,OU=JWICS
Users,dc=ds,dc=transcom,dc=ic,dc=gov\"\)\n");
print(W2KUSERS "Set UsrAtr = UsrObj.create\(\"User\", \"cn=$username\"\)\n");
print(W2KUSERS "UsrAtr\.Put \"saMAccountName\", \"$username\"\n");
print(W2KUSERS "UsrAtr\.Put \"givenName\", \"$givenName\"\n");
print(W2KUSERS "UsrAtr\.Put \"initials\", \"$initials\"\n");
print(W2KUSERS "UsrAtr\.Put \"sn\", \"$sn\"\n");
print(W2KUSERS "UsrAtr\.Put \"displayName\", \"$displayName $accesses\"\n");
print(W2KUSERS "UsrAtr\.Put \"description\", \"$displayName $accesses\"\n");
print(W2KUSERS "UsrAtr\.Put \"telephoneNumber\", \"$telephoneNumber\"\n");
print(W2KUSERS "UsrAtr\.Put \"physicalDeliveryOfficeName\", \"$Office_OU\"\n");
print(W2KUSERS "UsrAtr\.Put \"userPrincipalName\", \"$userPrincipalName\"\n");
print(W2KUSERS "UsrAtr\.Put \"homeDirectory\" , \"\\\\softserv\\$username\"\n");
print(W2KUSERS "UsrAtr\.Put \"homeDrive\" , \"H:\"\n");
print(W2KUSERS "UsrAtr\.Put \"profilePath\" , \"\\\\softserv\\user_profiles\\$username\"\n");
print(W2KUSERS "UsrAtr\.SetInfo\n\n");
close(W2KUSERS);
if ($OS =~ /Sun/) {
system("unix2dos $W2KUSERSfile $W2KUSERSfile");
system("chmod 666 $W2KUSERSfile");
}
 
Back
Top