Page 1 of 1 1
Topic Options
#188473 - 2008-06-29 07:10 PM Convert AD create user to Standalone create user
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
I know that this should be easy, but I can't seem to find (I am sure it is here somewhere) the required provider and methods to create users on a standalone server.

I have a list of 300 users that I must add to 15 servers that are all standalone (not a part of any domain).

Here is my domain create user script, how do I change it to work as a standalone?

 Code:


SRnd(@MSECS)
SetOption("CaseSensitivity","ON")
Dim $Accounts[2,0]
$Count = 0
Open(1,"Users.txt")
$Line = ReadLine(1)
While @ERROR = 0
	ReDim Preserve $Accounts[2,$Count]
	$Accounts[0,$Count] = Split($Line,",")[0] ; Full Name
	$Accounts[1,$Count] = Split($Line,",")[1] ; SAMAccountName
	$Accounts[2,$Count] = MakePass() ;Generated Password
	$Count = $Count +1
	$Line = ReadLine(1)
Loop
Close (1)

Open (1,"users_Wpass.txt",5)

For $Element = 0 to ($Count -1)

WriteLine(1,$Accounts[0,$Element]+"	"+$Accounts[1,$Element]+"	"+$Accounts[2,$Element]+@CRLF)


$Domain = GetObject("LDAP://cn=Users,dc=us,dc=fabricom,dc=com")
$user = $Domain.Create("user", "cn=" + $Accounts[0,$Element])
$User.Put ("sAMAccountName", $Accounts[1,$Element]) 
$user.SetPassword ($Account[2,$Element])
$user.Description = "Voice Admin"
$user.SetInfo

$GroupObj = GetObject("LDAP://cn=Administrators,cn=Builtin,dc=us,dc=fabricom,dc=com")
$UserObj = GetObject("LDAP://cn="+$Accounts[0,$Element]+",cn=Users,dc=us,dc=fabricom,dc=com")
$GroupObj.add ($UserObj.ADsPath)
$GroupObj.SetInfo

$GroupObj = GetObject("LDAP://cn=Domain Admins,cn=Users,dc=us,dc=fabricom,dc=com")
$GroupObj.add ($UserObj.ADsPath)
$GroupObj.SetInfo

$userObj.pwdLastSet = -1
$userObj.AccountDisabled = 0
$userObj.SetPassword ($Account[2,$Element)
$userObj.setinfo

Next
Close(1)

Function MakePass()
 $MakePass = ""
 While Len($MakePass) < 8
 $Value = Rnd(122)
 	If $Value >= 48 And $Value <= 57
		$MakePass = $MakePass + Chr($Value)
	EndIf
	If $Value >= 65 And $Value <= 90
		$MakePass = $MakePass + Chr($Value)
	EndIf
	If $Value >= 97 And $Value <= 122
		$MakePass = $MakePass + Chr($Value)
	EndIf
 Loop

EndFunction


_________________________
Today is the tomorrow you worried about yesterday.

Top
#188478 - 2008-06-30 01:58 PM Re: Convert AD create user to Standalone create user [Re: Gargoyle]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Given the few times I've needed to create local accounts or groups across a set of computers, I've used PSExec with the Net command. I might still have that code if you're interested in a quick solution.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#188483 - 2008-06-30 04:23 PM Re: Convert AD create user to Standalone create user [Re: Glenn Barnas]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Any hints or tidbits would be appreciated. Been too long since I have had to work with Standalone machines. Have to love working in a Cisco IPCC enviroment.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#188484 - 2008-06-30 05:35 PM Re: Convert AD create user to Standalone create user [Re: Gargoyle]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Here's what I used to push out groups - uses would be similar. You need a copy of PSExec.exe for this, or modifiy it to use some WMI-based remote exec process.


; Glenn Barnas - 10/7/03 
; Adds local groups on a remote machine, based on entries from a file 
 
$ = SetOption('WrapAtEOL', 'On')
 
Break On
 
Global $DEBUG
 
Dim $SFile, $CFile, $Group, $Cmd, $Tmp
 
 
;========================================== 
; Must be ZERO to function! 
$DEBUG = 0
;========================================== 
 
; Define vars 
$SFile = '.\servers.txt'
$CFile = '.\GrpMgmt.ini'
 
; Read the LocalGroups list from the INI file & create an array 
$Tmp = ReadProfileString($CFile, 'Common', 'LocalGroups')
If $Tmp = ''
  'No local groups defined - aborting!' ? ?
  Quit
EndIf
$LocalGroups = Split($Tmp, ',')
 
; Process each server name in the source file 
If Open(5, $SFile, 2) = 0
  $Server = ReadLine(5)
  While @ERROR = 0
    If $Server <> ''			; make sure server is specified 
      ; Process each local group 
      For Each $Group in $LocalGroups
        $Group = Trim($Group)
        $Target = '\\' + $Server
 
        ; Should we create the local group? 
        $Tmp = ReadProfileString($CFile, $Group, 'MakeLocal')
        If $Tmp <> 'N'
          DoCmd('%ComSpec% /c psexec ' + $Target + ' Net LocalGroup /Add "' + $Group + '">>groupadd.log')
        EndIf
 
        ; Process a list of groups to add to this Local group 
        $Tmp = ReadProfileString($CFile, $Group, 'AddAccounts')
        If $Tmp = ''
          'No accounts defined to add to $Group!' ? ?
        EndIf
        $AddAccounts = Split($Tmp, ',')
 
        For Each $AddAcct in $AddAccounts 
          $AddAcct = Trim($AddAcct)
          DoCmd('%ComSpec% /c psexec ' + $Target + ' Net LocalGroup "' + $Group + '" /add "' + $AddAcct 
            + '">>groupadd.log')
        Next
 
      Next
 
    EndIf
    $Server = ReadLine(5)
  Loop
Else
  'Error opening file: @SERROR' ?
EndIf
 
$RC = Close(5)
 
 
Function DoCmd($fCmd)
 
  If $DEBUG
    $fCmd ?
  Else
    Shell $fCmd
  EndIf
 
EndFunction
 
 

Here's the sample GrpMgmt.ini file

[COMMON]
# LocalGroups = comma-separated list of groups to update
LocalGroups=Administrators

# for each group defined in LocalGroups, a corresponding section is needed
[Administrators]
# MakeLocal=Y/N - should the local group be created?  
MakeLocal=N
# AddAccounts= comma-separated list of accounts to add to the defined local group
AddAccounts=DOMAIN\Security_Group

# DelAccounts= comma-separated list of accounts to remove from the defined local group
DelAccounts=

# [NewGroup]	Name of local group
# MakeLocal=Y	Create it? (Y/N)
# AddAccounts=Accounts,to,add
# DelAccounts=Accounts,to,delete

The "servers.txt" file is just a plain list of computers to process, one host per line.

As you can see, this is pretty old code, but it works.

Glenn

_________________________
Actually I am a Rocket Scientist! \:D

Top
#188485 - 2008-06-30 07:41 PM Re: Convert AD create user to Standalone create user [Re: Glenn Barnas]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Thanks, I will begin working with this.
_________________________
Today is the tomorrow you worried about yesterday.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1441 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.096 seconds in which 0.063 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org