#150607 - 2005-10-26 12:16 PM
create user in AD windows 2003
|
johndk
Fresh Scripter
Registered: 2004-11-25
Posts: 12
Loc: Denmark- horsens
|
The following script should create the users from at specified ttx file.
Tw script reads every string i neeed, but it does not put anything i AD.
Why not? 
Dim $LoginName, $NewUserAccount, $Container, $objGruppe1, $objGruppe2, $objGruppe3, $filesys, $filetxt, $strTemp, $strBruger, $strPassword, $strUdloeber, $strHomedir, $strUNCsti, $strFilsti $ForAppending $ForWriting $Forreading $forAppending='8' $ForWriting='2' $Forreading='1'
;$filesys = CreateObject("Scripting.FileSystemObject") ;$filetxt = $filesys.OpenTextFile("052ve.ttx", $ForReading, 1)
open(3, "052ve.ttx") $strLDAP=readline(3)
;*** START LÆS I FIL ***
;* Sætter stien til AD. Første linie i test.txt. If Not $filetxt.AtEndOfStream $strLDAP = Replace(filetxt.ReadLine, " ", "") EndIf ;* Læser en linie i filen. Klipper linien In stykker ved alle mellemrum. Sætter alle variabler, brugernavn mv. * ;* WScript.Echo viser en dialogboks med indholdet af variablen *
While readline(3) =0
$strTemp = ReadLine(3) sleep 0.5 ;* Brugernavn * $strBruger = Left($strTemp, (InStr($strTemp, ",")) - 1) ;* Fornavn * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strFornavn = Left($strTemp, (InStr($strTemp, ",")) - 1) ;* Efternavn * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strEfternavn = Left($strTemp, (InStr($strTemp, ",")) - 1) ;* Afdeling * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strAfdeling = Left($strTemp, (InStr($strTemp, ",")) - 1) ;* Gruppe1 * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strGruppe1 = Left($strTemp, (InStr($strTemp, ",")) - 1) ;* Gruppe2 * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strGruppe2 = Left($strTemp, (InStr($strTemp, ",")) - 1) ;* Gruppe3 * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strGruppe3 = Left($strTemp, (InStr($strTemp, ",")) - 1) ;* Udløber * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strUdloeber = Left($strTemp, (InStr($strTemp, ","))) ;* hold * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strhold = Left($strTemp, (InStr($strTemp, ",")) - 1) ;* Password * $strPassword = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) ;------------------------------------ ;*Set userfolder UNC And drive SOSFELEV If $strAfdeling="SOSHELEV" ;* UNCstien til userfolder $strUNCsti = "\\SOSHELEV\DATA\hold\" + $strHold + "\" ;* filepath til userfolder On server SOSHELEV strFilsti = "H:\hold\" + $strhold + "\" EndIf ;*Set userfolder UNC And drive SOSFELEV If $strAfdeling="SOSFELEV" ;* UNCstien til userfolder $strUNCsti = "\\SOSFELEV\DATA\hold\" + $strHold + "\" ;* filepath til userfolder On server SOSFELEV $strFilsti = "G:\hold\" + $strhold + "\" EndIf
;* home directory $strhomedir = $strUNCsti + "$strBruger" ;*** START inset In AD *** ;* connect To AF groups On SOSFELEV* If $strAfdeling = "SOSHELEV"
$Container = GetObject($strLDAP)
$objGruppe1 = GetObject("LDAP://cn=" + $strGruppe1 + ",OU=grupper i horsens,OU=grupper,DC=sosva,DC=elev") $objGruppe2 = GetObject("LDAP://cn=" + $strGruppe2 + ",OU=grupper i horsens,OU=grupper,DC=sosva,DC=elev") $objGruppe3 = GetObject("LDAP://cn=" + $strGruppe3 + ",OU=grupper,DC=sosva,DC=elev") EndIf ;* connect To AF groups On SOSFELEV* If $strAfdeling="SOSFELEV"
$Container = GetObject($strLDAP)
$objGruppe1 = GetObject("LDAP://cn=" + $strGruppe1 + ",OU=grupper i fredericia,OU=grupper,DC=sosva,DC=elev") $objGruppe2 = GetObject("LDAP://cn=" + $strGruppe2 + ",OU=grupper i fredericia,OU=grupper,DC=sosva,DC=elev") $objGruppe3 = GetObject("LDAP://cn=" + $strGruppe3 + ",OU=grupper,DC=sosva,DC=elev")
EndIf
;* Opretter den nye bruger * ;Creates account $NewUserAccount = $Container.Create("User, CN=" + $strBruger) ;Sets login name $NewUserAccount.SamAccountName = $strBruger ;Sets Fornavn $NewUserAccount.givenName = $strFornavn ;Sets Fornavn $NewUserAccount.sn = $strEfternavn ;Sets Logonbat $NewUserAccount.ScriptPath = "wkix32.exe login.kix" ;Sets Homedir $NewUserAccount.HomeDirectory = $strHomedir ;Sets HomeDrive $NewUserAccount.HomeDrive = "T:" ;Sets logon W2k $NewUserAccount.userPrincipalName = $strBruger ;Sets Homedir $NewUserAccount.HomeDirectory = $strUNCsti + $strBruger ;Sætter profil stien - Fjern ; nedenunder For at For profil stien med. ; NewUserAccount.profilePath = strUNCsti + strBruger + "\profil" ;Sets Account udløber $NewUserAccount.AccountExpirationDate = $strUdloeber ;Writes information To directory $NewUserAccount.Setinfo ;Sets password To password $NewUserAccount.SetPassword $strPassword ;Sets Password udløbet $NewUserAccount.pwdLastSet = '-1' $NewUserAccount.Setinfo ;Enables account ; sætter kodeord til at være udløbet og skal ændres ; NewUserAccount.UserAccountControl = NewUserAccountControl And Not +H200 $NewUserAccount.UserAccountControl = $NewUserAccountControl And +H200 And +h10000 $NewUserAccount.Setinfo ;Tilføjer bruger til grupper $objGruppe1.Add $NewUserAccount.ADSPath $objGruppe2.Add $NewUserAccount.ADSPath $objGruppe3.Add $NewUserAccount.ADSPath OpretMappe($strBruger) loop
;*** NED PUT I AD ***
;------------------------------------
? "The command completed successfully."
Function OpretMappe($strUser) ? "opret funktion" sleep 1 $WshNetwork = CreateObject("Network") $WshShell = CreateObject("Shell") $newfolderpath = $strFilSti + $strUser $filesys=CreateObject("Scripting.FileSystemObject") If Not $filesys.FolderExists($newfolderpath) $newfolder = $filesys.CreateFolder($newfolderpath) EndIf
Run "xcacls" + $strFilsti + $strUser + " /p sosva-E\" + $strUser + ":c "+"sosva-E\domain-admins:F "+"sosva-e\SSA-laerer:F"+" /y"
EndFunction
Function Replace($String,$SS,$RS) $Replace=Join(Split($String,$SS),$RS) EndFunction
eks. on ttx-file LDAP://OU=052ve,OU=hold/fr,DC=sosva,DC=elev 994,Majbritt Berit Friis,Andersen,SOSFELEV,fre-elev,fre-kursus,alle,05/11/05,052ve,5301 3442,Linda S.H.,Mathiasen,SOSFELEV,fre-elev,fre-kursus,alle,05/11/05,052ve,18357 4180,Pia,Holdorff,SOSFELEV,fre-elev,fre-kursus,alle,05/11/05,052ve,22293 5329,Helle,Dantoft,SOSFELEV,fre-elev,fre-kursus,alle,05/11/05,052ve,28421 10104,Susanne,Mikkelsen,SOSFELEV,fre-elev,fre-kursus,alle,05/11/05,052ve,53888 10157,Pia,Hentzen,SOSFELEV,fre-elev,fre-kursus,alle,05/11/05,052ve,54171 10244,Heidi,Cortsen,SOSFELEV,fre-elev,fre-kursus,alle,05/11/05,052ve,54635
|
|
Top
|
|
|
|
#150609 - 2005-10-26 02:20 PM
Re: create user in AD windows 2003
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Your main problem is probably your incorrect hex notation.
From your script: Quote:
NewUserAccount.UserAccountControl = $NewUserAccountControl And +H200 And +h10000
From the manual: Quote:
Hexadecimal notation:
[-|+]<&digits>
Also these values need to be bitwise OR'ed. Your logical AND is not correct.
From manual: Quote:
| Performs a bit-wise mathematical OR operation on two numbers
Edited by Howard Bullock (2005-10-26 02:21 PM)
|
|
Top
|
|
|
|
#150610 - 2005-10-27 01:22 PM
Re: create user in AD windows 2003
|
johndk
Fresh Scripter
Registered: 2004-11-25
Posts: 12
Loc: Denmark- horsens
|
Know i have tried too change the script, but It gives my no error and i does not put anything i AD Code:
Dim $LoginName, $NewUserAccount, $Container, $objGruppe1, $objGruppe2, $objGruppe3, $filesys, $filetxt, $strTemp, $strBruger, $strPassword, $strUdloeber, $strHomedir, $strUNCsti, $strFilsti $ForAppending $ForWriting $Forreading $forAppending='8' $ForWriting='2' $Forreading='1'
;$filesys = CreateObject("Scripting.FileSystemObject") ;$filetxt = $filesys.OpenTextFile("052ve.ttx", $ForReading, 1)
open(3, "052ve.ttx") $strLDAP=readline(3)
;*** START LÆS I FIL ***
;* Sætter stien til AD. Første linie i test.txt. If Not $filetxt.AtEndOfStream $strLDAP = Replace(filetxt.ReadLine, " ", "") EndIf ;* Læser en linie i filen. Klipper linien In stykker ved alle mellemrum. Sætter alle variabler, brugernavn mv. * ;* WScript.Echo viser en dialogboks med indholdet af variablen *
;While readline(3) =0
$strTemp = ReadLine(3) sleep 0.5 ;* Brugernavn * $strBruger = Left($strTemp, (InStr($strTemp, ",")) - 1) ;* Fornavn * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strFornavn = Left($strTemp, (InStr($strTemp, ",")) - 1) ;* Efternavn * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strEfternavn = Left($strTemp, (InStr($strTemp, ",")) - 1) ;* Afdeling * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strAfdeling = Left($strTemp, (InStr($strTemp, ",")) - 1) ;* Gruppe1 * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strGruppe1 = Left($strTemp, (InStr($strTemp, ",")) - 1) ;* Gruppe2 * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strGruppe2 = Left($strTemp, (InStr($strTemp, ",")) - 1) ;* Gruppe3 * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strGruppe3 = Left($strTemp, (InStr($strTemp, ",")) - 1) ;* Udløber * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strUdloeber = Left($strTemp, (InStr($strTemp, ","))) ;* hold * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strhold = Left($strTemp, (InStr($strTemp, ",")) - 1) ;* Password * $strPassword = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) ;------------------------------------ ;*Set userfolder UNC And drive SOSFELEV If $strAfdeling="SOSHELEV" ;* UNCstien til userfolder $strUNCsti = "\\SOSHELEV\DATA\hold\" + $strHold + "\" ;* filepath til userfolder On server SOSHELEV strFilsti = "H:\hold\" + $strhold + "\" EndIf ;*Set userfolder UNC And drive SOSFELEV If $strAfdeling="SOSFELEV" ;* UNCstien til userfolder $strUNCsti = "\\SOSFELEV\DATA\hold\" + $strHold + "\" ;* filepath til userfolder On server SOSFELEV $strFilsti = "G:\hold\" + $strhold + "\" EndIf
;* home directory $strhomedir = $strUNCsti + "$strBruger" ;*** START inset In AD *** ;* connect To AF groups On SOSFELEV* If $strAfdeling = "SOSHELEV" ? "er på horsens server" $Container = GetObject($strLDAP)
$objGruppe1 = GetObject("LDAP://cn=" + $strGruppe1 + ",OU=grupper i horsens,OU=grupper,DC=sosva,DC=elev") $objGruppe2 = GetObject("LDAP://cn=" + $strGruppe2 + ",OU=grupper i horsens,OU=grupper,DC=sosva,DC=elev") $objGruppe3 = GetObject("LDAP://cn=" + $strGruppe3 + ",OU=grupper,DC=sosva,DC=elev") EndIf ;* connect To AF groups On SOSFELEV* If $strAfdeling="SOSFELEV" ? "er på Fredericia server" ? $strLDAP $Container = GetObject($strLDAP) $objGruppe1 = GetObject("LDAP://cn=" + $strGruppe1 + ",OU=grupper i fredericia,OU=grupper,DC=sosva,DC=elev") $objGruppe2 = GetObject("LDAP://cn=" + $strGruppe2 + ",OU=grupper i fredericia,OU=grupper,DC=sosva,DC=elev") $objGruppe3 = GetObject("LDAP://cn=" + $strGruppe3 + ",OU=grupper,DC=sosva,DC=elev")
EndIf
;* Opretter den nye bruger * ;Creates account $AdsUser = $Container.Create("User", "CN="+$strBruger) ;Sets login name $AdsUser.Put("SamAccountName",$strBruger) ;Sets Fornavn $AdsUser.Put("givenName",$strFornavn) $AdsUser.Put("FirstName",$strFornavn) ;Sets efternavn $AdsUser.Put("Lastname",$strEfternavn) $AdsUser.put("sn",$strEfternavn) $adsuser.Put("Description ",$strhold) ;Sets Logonbat $AdsUser.put("ScriptPath","wkix32.exe /I login.kix") ;Sets Homedir $AdsUser.put("HomeDirectory",$strHomedir) ;Sets HomeDrive $AdsUser.put("HomeDrive","T:") ;Sets logon W2k $AdsUser.put("userPrincipalName",$strBruger) ;Sets Homedir $AdsUser.Put("HomeDirectory",$strUNCsti + $strBruger) ;Sætter profil stien - Fjern ; nedenunder For at For profil stien med. $AdsUser.Put("profilePath",strUNCsti + strBruger + "\profil") ;Sets Account udløber $AdsUser.Put("AccountExpirationDate",$strUdloeber) ;Writes information To directory $AdsUser.Setinfo ;Sets password To password $AdsUser.SetPassword("$strPassword") ;Sets Password udløbet $AdsUser.put("pwdLastSet", -1) $AdsUser.SetInfo sleep 1 $CreateUserAccount = @error sleep 1 if $CreateUserAccount ? "SetInfo Error: " + @error + " " + @Serror sleep 4 endif
;Enables account ; sætter kodeord til at være udløbet og skal ændres ; NewUserAccount.UserAccountControl = NewUserAccountControl And Not +H200 $AdsUser.UserAccountControl("NewUserAccountControl", +H200, +h10000) ;Tilføjer bruger til grupper $objGruppe1.Add ("LDAP://CN=$strbruger,ou=$strhold,DC=sosva,DC=elev") $objGruppe2.Add ("LDAP://CN=$strbruger,ou=$strhold,DC=sosva,DC=elev") $objGruppe3.Add ("LDAP://CN=$strbruger,ou=$strhold,DC=sosva,DC=elev") OpretMappe($strBruger) ;loop
;*** SLUT INDSÆT I AD ***
;------------------------------------
? "The command completed successfully."
Function OpretMappe($strUser) ? "opret funktion" sleep 1 $WshNetwork = CreateObject("Network") $WshShell = CreateObject("Shell") $newfolderpath = $strFilSti + $strUser $filesys=CreateObject("Scripting.FileSystemObject") If Not $filesys.FolderExists($newfolderpath) $newfolder = $filesys.CreateFolder($newfolderpath) EndIf
Run "xcacls" + $strFilsti + $strUser + " /p sosva-E\" + $strUser + ":c "+"sosva-E\domain-admins:F "+"sosva-e\SSA-laerer:F"+" /y"
EndFunction
Function Replace($String,$SS,$RS) $Replace=Join(Split($String,$SS),$RS) EndFunction
Edited by Howard Bullock (2005-10-28 03:28 AM)
|
|
Top
|
|
|
|
#150612 - 2005-10-28 03:41 AM
Re: create user in AD windows 2003
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Quote:
$AdsUser.UserAccountControl("NewUserAccountControl", +H200, +h10000)
Again this is wrong. Please read the "expressions" section of the manual for proper hex notation.
&200, &10000
See: http://support.microsoft.com/default.aspx?scid=kb;en-us;305144
Code:
usr.Put ("userAccountControl", (&200 | &10000)) ? @serror
or
Code:
usr.userAccountControl = (&200 | &10000)) ? @serror
Until you fully understand ADSI methods, I would suggest checking the @error and @serror macros after setting each property.
|
|
Top
|
|
|
|
#150613 - 2005-10-31 02:50 PM
Re: create user in AD windows 2003
|
johndk
Fresh Scripter
Registered: 2004-11-25
Posts: 12
Loc: Denmark- horsens
|
Thank you very much for all your help.
It is now running and create a user.
but i have now 2 other problems.
1) i want to read the second linie in data-file and do until EOF
2) I want to browse for a data-file, because the fil-name of data-file is varies
Dim $LoginName, $NewUserAccount, $Container, $objGruppe1, $objGruppe2, $objGruppe3, $filesys, $filetxt, $strTemp, $strBruger, $strPassword, $strUdloeber, $strHomedir, $strUNCsti, $strFilsti $ForAppending $ForWriting $Forreading $forAppending='8' $ForWriting='2' $Forreading='1'
;$filesys = CreateObject("Scripting.FileSystemObject") ;$filetxt = $filesys.OpenTextFile("052ve.ttx", $ForReading, 1)
Dim $lf, $f, $_,$t $lf=chr(10) $f=Freefilehandle
open($f, "052ve.ttx") $strLDAP=readline($f) $Container = GetObject($strLDAP)
;*** START LÆS I FIL ***
;* Sætter stien til AD. Første linie i test.txt. If Not $filetxt.AtEndOfStream $strLDAP = Replace(filetxt.ReadLine, " ", "") EndIf ; should read the next line and curt the line in to pieces. ; Should do it until nu more linie in ttx-file.
; I WANT TO START TO READ THE sECOND LINE IN FILE ; AND Do aLL THE BELOW ;AND THE THE NExT LINE AND DO BELOW ; UNTIL EOF
DO ;* Brugernavn * $strBruger = Left($strTemp, (InStr($strTemp, ",")) - 1) ? $strBruger ;* Fornavn * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strFornavn = Left($strTemp, (InStr($strTemp, ",")) - 1) ? $strfornavn ;* Efternavn * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strEfternavn = Left($strTemp, (InStr($strTemp, ",")) - 1) ? $strefternavn ;* Afdeling * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strAfdeling = Left($strTemp, (InStr($strTemp, ",")) - 1) ? $strafdeling ;* Gruppe1 * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strGruppe1 = Left($strTemp, (InStr($strTemp, ",")) - 1) ? $strgruppe1 ;* Gruppe2 * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strGruppe2 = Left($strTemp, (InStr($strTemp, ",")) - 1) ? $strgruppe2 ;* Gruppe3 * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strGruppe3 = Left($strTemp, (InStr($strTemp, ",")) - 1) ? $strgruppe3
;* Udløber * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strUdloeber = Left($strTemp, (InStr($strTemp, ","))) ? $strudloeber
;* hold * $strTemp = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) $strhold = Left($strTemp, (InStr($strTemp, ",")) - 1) ? $strhold
;* Password * $strPassword = Right($strTemp, Len($strTemp) - InStr($strTemp, ",")) ? $strpassword
;------------------------------------ ;*Set userfolder UNC And drive SOSFELEV
If $strAfdeling="SOSHELEV" ? "UNCsti for Horsens" ;* UNCstien til userfolder $strUNCsti = "\\SOSHELEV\DATA\hold\" + $strHold + "\" ;* filepath til userfolder On server SOSHELEV strFilsti = "H:\hold\" + $strhold + "\" EndIf ;*Set userfolder UNC And drive SOSFELEV
If $strAfdeling="SOSFELEV" ? "UNCsti for Fredericia" ;* UNCstien til userfolder $strUNCsti = "\\SOSFELEV\DATA\hold\" + $strHold + "\" ? $strUNCsti ;* filepath til userfolder On server SOSFELEV $strFilsti = "G:\hold\" + $strhold + "\" ? $strfilSti sleep 2 EndIf
;* home directory $strhomedir = $strUNCsti+$strBruger ;*** START inset In AD *** ;* connect To AF groups On SOSFELEV* If $strAfdeling = "SOSHELEV" ? "er på horsens server"
$objGruppe1 = GetObject("LDAP://cn=" + $strGruppe1 + ",OU=grupper i horsens,OU=grupper,DC=sosva,DC=elev") $objGruppe2 = GetObject("LDAP://cn=" + $strGruppe2 + ",OU=grupper i horsens,OU=grupper,DC=sosva,DC=elev") $objGruppe3 = GetObject("LDAP://cn=" + $strGruppe3 + ",OU=grupper,DC=sosva,DC=elev") EndIf ;* connect To AF groups On SOSFELEV* If $strAfdeling="SOSFELEV" ? "er på Fredericia server" $objGruppe1 = GetObject("LDAP://cn=$strGruppe1,OU=grupper i fredericia,OU=grupper,DC=sosva,DC=elev") $objGruppe2 = GetObject("LDAP://cn=$strGruppe2,OU=grupper i fredericia,OU=grupper,DC=sosva,DC=elev") $objGruppe3 = GetObject("LDAP://cn=$strGruppe3,OU=grupper,DC=sosva,DC=elev")
EndIf ? $strbruger
;* Opretter den nye bruger * ;Creates account $AdsUser = $Container.Create("User","cn="+$strBruger) ;Sets login name $AdsUser.Put("SamAccountName",$strBruger) ;Sets Fornavn $AdsUser.Put("givenName",$strFornavn) ;Sets efternavn $AdsUser.put("sn",$strEfternavn) ; $adsuser.Put("Description ",$strhold) ; ? "description" @error ; $Adsuser.SetInfo() ; ? "vi prøver lige her" @error @serror
;Sets Logonbat $AdsUser.put("ScriptPath","wkix32.exe /i login.kix")
;Sets Homedir $AdsUser.put("HomeDirectory",$strHomedir) ;Sets HomeDrive $AdsUser.put("HomeDrive","T:")
;Sets logon W2k $AdsUser.put("userPrincipalName",$strBruger) ;Sætter profil stien - Fjern ; nedenunder For at For profil stien med. ; $AdsUser.Put("profilePath",strUNCsti + strBruger + "\profil") ; ? "profil" @error
;Sets Password udløbet ; $AdsUser.pwdLastSet=-1 ; ? "pwdlastset" @error $Adsuser.SetInfo()
;Enables account ; sætter kodeord til at være udløbet og skal ændres ; NewUserAccount.UserAccountControl = NewUserAccountControl And Not +H200 $Adsuser.Put ("userAccountControl", (&200 | &10000))
;Sets password To password
$AdsUser.SetPassword($strPassword) $Adsuser.SetInfo()
;Tilføjer bruger til grupper $DomainString = @DOMAIN $UserString = $strBruger $GroupString = $strgruppe1 $GroupObj = GetObject("WinNT://" + $DomainString + "/" + $GroupString) $GroupObj.Add ("WinNT://" + $DomainString + "/" + $UserString) $DomainObj = "" $GroupObj = ""
$GroupString = $strgruppe2 $GroupObj = GetObject("WinNT://" + $DomainString + "/" + $GroupString) $GroupObj.Add ("WinNT://" + $DomainString + "/" + $UserString) $DomainObj = "" $GroupObj = ""
$GroupString = $strgruppe3 $GroupObj = GetObject("WinNT://" + $DomainString + "/" + $GroupString) $GroupObj.Add ("WinNT://" + $DomainString + "/" + $UserString) $DomainObj = "" $GroupObj = ""
OpretMappe($strBruger,$strfilsti)
If @error exit @error endif
until @error
close($f) ;*** SLUT INDSÆT I AD ***
;------------------------------------
? "The command completed successfully."
Function OpretMappe($strUser,$strsti) ? "opret funktion" sleep 1 ? $strsti ? $strUser $WshNetwork = CreateObject("Network") $WshShell = CreateObject("Shell") $newfolderpath = $strsti + $struser ? $newfolderpath
$filesys=CreateObject("Scripting.FileSystemObject") If Not $filesys.FolderExists($newfolderpath) $newfolder = $filesys.CreateFolder($newfolderpath) EndIf ? $strsti ? $struser Run "e:\elevoprettelse\xcacls.exe "+ $strsti + $strUser + " /p sosva-E\" + $strUser + ":c "+"sosva-E\domain-admins:F "+"sosva-e\SSA-laerer:F"+" /y"
sleep 5 ; Run "xcacls.exe" + $strFilsti + $strUser + " /p sosva-E\" + $strUser + ":c "+"sosva-E\domain-admins:F "+"sosva-e\SSA-laerer:F"+" /y"
EndFunction
Function Replace($String,$SS,$RS) $Replace=Join(Split($String,$SS),$RS) EndFunction
1)
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 756 anonymous users online.
|
|
|