komt ie...
==========
;****************************************************************
;
;*** New user gui interface
;***
;*** Purpose: creates NT account and Home drive for a user
;*** from a single interface
;***
;*** by ArCadE
;*** copyright 2002
;*** Thanks to everyone at kixtart.org for ideas
;***
;***
;*** Script requirements:
;*** NTResourcekit loaded
;*** Xcacls loaded and in path
;*** Administrator perms on domains
;***
;*** resource files:
;*** $domainfile - ini format file with domain information
;***
;*** optional file:
;*** $logfile - for logging usage of script and tracking creation of accounts
;***
;************************************************
;Variables needed to send to create accounts
;Emp ID required, must be validated
;First Name required
;Last Name required
;Username required
;Domain required
;Options
;Create NT Account (Y/N)
;Create Home Drive (Y/N)
;************************************************
break on
;*** calls three files which contain the dropdown list data
;*** File Format
$utildir = "C:\Temp\Test\GUI"
$domainfile = $utildir + "\domains.txt" ; INI style
$logfile = $utildir + "\lognug.txt" ;log file for script usage
$BackGround = $utildir +"\create_logo.gif"
;****************************************************************
If @inwin = 2
? "This script will not Run on a win9x system."
sleep 1
? "Exiting..."
sleep 1
exit
endif
DIM $top
DIM $left
DIM $height
DIM $width
DIM $False
DIM $true
DIM $title
DIM $status
DIM $doc
DIM $nul
DIM $html
GLOBAL $FName ;First name
GLOBAL $Lname ;Last Name
GLOBAL $Uname ;User name
GLOBAL $domain ;Domain name
GLOBAL $options ;temp
GLOBAL $domainoptions ;Used to store domain list
GLOBAL $numdomains ;used to store the number of domains
$cr = chr(13) + chr(10)
$Fname = ""
$Lname = ""
$Uname = ""
$Mname = ""
$domain = ""
;****************************************************************
;domains
DIM $domainname[10]
DIM $domaindisp[10]
DIM $domainDrive[10]
$line = ""
$domainoptions = ""
$numdomains = readprofilestring($domainfile,"Domains","Number")
$line = "First"
$domainindex = 0
? ? "Loading domains" ?
while $domainindex <= $numdomains
$domname = readprofilestring($domainfile,"$Domainindex","name")
$domdrive = readprofilestring($domainfile,"$Domainindex","userserver")
$domdisplay = $domname
$domainname[$domainindex] = $domname
$domainDrive[$domainindex] = $domDrive
$domaindisp[$domainindex] = $domdisplay
$domainindex = $domainindex + 1
"."
loop
$i = 1
while $i < $domainindex
$Optionname = $domainname[$i]
$domainoptions = $domainoptions + '<option value="$i">$optionname</option>' + $cr
$i = $i + 1
loop
" Done"
;end domains
;****************************************************************
;****************************************************************
$title = "New User Script"
$top = "100"
$left = "100"
$height = "400"
$width = "500"
$false = 0
$true = -1
Gosub HTML
Gosub IE
$nul = Setconsole("HIDE")
; Get the valueof the status control ...
$Status = olegetproperty (val("&" + olecallfunc($doc,"GetElementById","s","status")), "value" )
; Main Command Loop
while @error = 0 and $status <> ""
select
case $status = "1" ; Submit was clicked
$Fname = olegetproperty(val("&" + olecallfunc($doc, "GetElementById","s","fname")), "value")
$Lname = olegetproperty(val("&" + olecallfunc($doc, "GetElementById","s","lname")), "value")
$Uname = olegetproperty(val("&" + olecallfunc($doc, "GetElementById","s","uname")), "value")
$domain = olegetproperty(val("&" + olecallfunc($doc, "GetElementById","s","domain")), "value")
$NTYN = olegetproperty(val("&" + olecallfunc($doc, "GetElementById","s","NTYN")), "value")
; Reset the status value to zero ...
$nul = oleputproperty(val("&" + olecallfunc($doc,"GetElementById","s","status")),"value","s","0")
gosub createaccounts ;sends information to create the accounts
$nul = setfocus("$title") ;resets focus to main ole page
$nul = sendkeys({F5}) ;refreshes/clears page
case $status = "2" ;Cancel was clicked.
gosub Finish
exit
case $status = "3"
; Reset the status value to zero ...
$nul = oleputproperty(val("&" + olecallfunc($doc,"GetElementById","s","status")),"value","s","0")
$nul = sendkeys({F5})
endselect
; Get the valueof the status control ...
$Status = olegetproperty (val("&" + olecallfunc($doc,"GetElementById","s","status")), "value" )
loop
;****************************************************************
;***
;*** End of script
;***
:finish
; Object cleanup ...
$nul = olecallfunc ( $doc, "close" )
$nul = olereleaseobject ( $doc )
$nul = olecallfunc ( $ie, "quit" )
$nul = olereleaseobject ( $ie )
$nul = Setconsole("SHOW")
? "Script ended successfully"
sleep 2
Return
;***
;*** End of script
;***
;****************************************************************
;****************************************************************
;***
;*** Begin Subroutines
;***
;****************************************************************
;***
;*** This routine create the ole object
;***
:IE
$ie = olecreateobject("internetexplorer.application")
if $ie = 0 exit endif
; Set properties and display form ...
$nul = oleputproperty($ie, "addressbar","s","$false")
$nul = oleputproperty($ie, "menubar", "s", "$false")
$nul = oleputproperty($ie, "toolbar", "s", "$false")
;$nul = oleputproperty($ie, "statusbar", "s", "$false")
;$nul = oleputproperty($ie, "resizable", "s", "$false")
$nul = oleputproperty($ie, "top", "s", "$top")
$nul = oleputproperty($ie, "left", "s", "$left")
$nul = oleputproperty($ie, "height", "s", "$height")
$nul = oleputproperty($ie, "width", "s", "$width")
;$nul = oleputproperty($ie, "visible", "s", "$true")
$nul = olecallfunc($ie, "navigate", "s", "about:blank")
$current = olegetproperty($ie, "busy")
while olegetproperty($ie, "busy") <> "0" and @error = 0 loop
; Get a handle to the open document ...
$doc = val("&" + olegetproperty($ie, "document"))
$nul = olecallfunc($doc, "write", "s", "$html")
;setconsole("Hide")
while setfocus("$title") <> 0 loop
$nul = sendkeys({F5})
return
;****************************************************************
;***
;*** HTML Code for the ole object. Including background VBscript
;***
:html
$html = '<html>
<head>
<title>' + $title + '</title>
<body background="$BackGround" bgcolor="#0000FF" scroll="no">
<div align="center"><center>
<style><!---body{ background-color: black; color: white;
font-family: tahoma, arial; font-size: 10pt; margin: 3px "
input.tbox { border: lpx white solid;}
td { font: 10pt tahoma; }
---></style>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Makeuname
Dim Firstname
Dim Lastname
Dim finit
Dim Username
Dim init
Firstname = lcase(frm.fname.value)
finit = left(Firstname,1)
Firstname = lcase(mid(Firstname,2))
Firstname = ucase(finit) & Firstname
frm.fname.value = Firstname
Lastname = lcase(frm.lname.value)
init = left(Lastname,1)
Lastname = lcase(mid(Lastname,2))
Lastname = ucase(init) & Lastname
frm.lname.value = Lastname
frm.Uname.value = lcase(frm.Uname.value)
end sub
Sub Fname_OnChange
call Makeuname
End Sub
Sub Lname_OnChange
call Makeuname
End Sub
Sub Uname_OnChange
call Makeuname
End Sub
Sub cmdSubmit_OnClick
If validate = True Then
frm.status.value=1
end if
End Sub
Sub cmdAbout_OnClick
msgbox("New User Accounts by ArCadEl")
End Sub
Msgbox ("Please enter the First name")
frm.fname.focus
else
If frm.lname.value = "" Then
Msgbox("Please enter the Last name")
frm.lname.focus
else
If frm.uname.value = "" Then
Msgbox("Please enter the User name")
frm.uname.focus
else
If frm.domain.value = "nul" Then
Msgbox("Please select the domain")
frm.domain.focus
else
validate = True
end if
end if
end if
end if
end function
-->
</SCRIPT>
</head>
<body>
<form name="frm">
<p> </p>
<table border="1" width="400" height="150">
<tr>
<td width="324" height="20">First Name </td>
<td width="124" height="20">Last Name </td>
</tr>
<tr>
<td width="324" height="24"><input Id="Fname" type="textbox" name="Fname" size="20"></td>
<td width="124" height="24"><input Id="Lname" type="textbox" name="Lname" size="20"></td>
</tr>
<tr>
<td width="219" height="24">Username
<td width="124" height="24"></td>
</tr>
<tr>
<td width="242" height="21"><input Id="Uname" type="textbox" name="Uname" size="20"></td>
<td width="448" colspan="2" height="21"></td>
</tr>
<tr>
<td width="242" height="21"></td>
<td width="448" colspan="2" height="21"></td>
</tr>
<tr>
<td width="277" height="25">Domain</td>
</tr>
<tr>
<td width="277" height="25"><select Id="domain" size="1" name="lstDomain">
<option value="nul">--- Select An Option ---</option>' + $domainoptions + '
</select></td>
</tr>
<tr>
<td width="250" height="15"></td>
</tr>
<tr>
<td height="4">Create NT Account?</td>
<td height="4" colspan="2"><table border="1">
<tr><input type=hidden id=NTyn value="Y">
<td><input type="radio" name="radNTYN" onclick=frm.NTyn.value="Y" value="Y">Yes</td>
<td><input type="radio" name="radNTYN" onclick=frm.NTyn.value="N" value="N" checked>No</td>
</tr>
</table>
</td>
<td height="4"></td>
</tr>
<tr>
<td height="4"></td>
<td height="4" colspan="2"></td>
<td height="4"></td>
</tr>
</table>
<pre>
</pre>
<table border="0"><input type=hidden id=status value=0>
<tr>
<td height="25"><input name="cmdSubmit" id="cmdSubmit" type="button" value=" Submit "></td>
<td height="25"><input id="close" type="button" value=" Close " onclick="frm.status.value=2"></td>
<td width="125" height="25"></td>
<td height="25"><input name = "cmdReset" id="cmdReset" type="button" value=" Reset " onclick="frm.status.value=3"></td>
<td height="25"><input name="cmdAbout" id="cmdAbout" type="button" value="About"></td>
</tr>
</table>
<pre>
</pre>
</form>
</body>
</html>
'
return
;***
;*** HTML Code
;***
;****************************************************************
;****************************************************************
;****************************************************************
;***
;*** Begin processing info from gui
;***
;*** Script requirements:
;*** NTResourcekit loaded
;*** Xcacls loaded and in path
;*** Administrator perms on domains
:createaccounts
$userdomain = readprofilestring($domainfile,"$Domain","Name")
gosub log
;************************************************
;Variables needed to send to create accounts
;Emp ID required, must be validated
;First Name required
;Last Name required
;Username required
;Department required
;Domain required
;Options
;Create NT Account (Y/N)
;Create/Modify Home Drive (Y/N)
;************************************************
;*******************************************************
;***
;*** NT account
;***
if $NTYN = "Y"
$userdomain = readprofilestring($domainfile,"$Domain","Name")
$userserver = readprofilestring($domainfile,"$Domain","userserver")
$userhome = lcase($Uname)
$message = "Create user account $Uname on $userdomain?"
$title = "Confirm User account"
$result = messagebox("$message","$title",4132)
$password=password
sleep 1
if $result = 6
$script = readprofilestring($domainfile,"$Domain","script")
$DefGrp1 = readprofilestring($domainfile,"$Domain","DefGrp1")
$DefGrp2 = readprofilestring($domainfile,"$Domain","DefGrp2")
$HomeDrive = readprofilestring($domainfile,"$Domain","homedrive")
$HomeMap = "\\"+$userserver+"\"+$Uname
$Displayname = "$Lname, $Fname"
$server = readprofilestring($domainfile,"$Domain","PDC")
$userfile1 = '[user]' + $cr + '$Uname!$displayname!$password!!$HomeDrive!$HomeMap$!!$script' + $cr
$userfile = $utildir + "\makeuser.csv"
if exist($userfile) del "$userfile" endif ;delete temp file
$nul = open (7,$userfile,1) $nul = close(7) ;create file
$nul = open(7,$userfile,4) ;Enter emp info in new file
$nul = writeline(7,"$userfile1")
$nul = close(7)
shell ('addusers \\$server /c $userfile /s:!')
del "$userfile" ;delete temp file
if $userdomain = @domain
shell ('%comspec% /c net group $DefGrp1 $Uname /add /domain')
shell ('%comspec% /c net group $DefGrp2 $Uname /add /domain')
else
$grp_file1 = $utildir + "\grp_user1.txt"
$grp_file2 = $utildir + "\grp_user2.txt"
$nul = open(7,$grp_file1,1) $nul = close(7) ;create file
$nul = open(7,$grp_file1,4) ;Enter empty info in new file
$nul = writeline(7,"Domain: $userdomain" + $cr)
$nul = writeline(7,"Globalgroup: $DefGrp1" + $cr)
$nul = writeline(7,"$Uname" + $cr)
$nul = close(7)
shell ('%comspec% /c usrtogrp $grp_file1')
del "$grp_file1" ;delete temp file
$nul = open(7,$grp_file2,1) $nul = close(7) ;create file
$nul = open(7,$grp_file2,4) ;Enter empty info in new file
$nul = writeline(7,"Domain: $userdomain" + $cr)
$nul = writeline(7,"Globalgroup: $DefGrp2" + $cr)
$nul = writeline(7,"$Uname" + $cr)
$nul = close(7)
shell ('%comspec% /c usrtogrp $grp_file2')
del "$grp_file2" ;delete temp file
endif
$message = "Create home drive" + $cr + "\\$userserver\users$\$userhome ??"
$title = "Confirm User Drive"
$result = messagebox("$message","$title",4132)
sleep 1
if $result = 6
if $userserver = ""
messagebox("No User drive specified for this location, Please create desired drive manually","Home Drive Error",4144)
else
? "Creating drive"
SHELL '%COMSPEC% /E:1024 /C md "\\$userserver\E$\users\$userhome"'
if @error = 183
$nul = messagebox("Directory already exists","Warning",4144)
endif
sleep 1
SHELL '%COMSPEC% /E:1024 /C nltest /SERVER:$server /pdc_repl'
SHELL '%COMSPEC% /E:1024 /C rmtshare \\$userserver\$Uname$$="E:\Users\$Uname" /REMARK:"" > NUL:'
SHELL '%COMSPEC% /E:1024 /C xcacls \\$userserver\users$\$Uname /T /C /G Administrators:F /Y'
SHELL '%COMSPEC% /E:1024 /C xcacls \\$userserver\users$\$Uname /T /C /E /G $userdomain\$Uname:C /Y'
sleep 5
endif
endif
endif
endif
;endif
return
;***
;*** Create log file to track accounts added using script
;***
:log
if exist("$logfile") = 0
$nul = open(7,$logfile,1)
$nul = close(7)
$linetowrite = 'userid,date,time,Uname,fname,lname,domain' + $cr
$nul = open(7,$logfile,4)
$nul = writeline(7,$linetowrite)
$nul = close(7)
endif
$linetowrite = '@userid,@date,@time,$Uname,$fname,$lname,$userdomain' + $cr
$nul = open(7,$logfile,4)
$nul = writeline(7,$linetowrite)
$nul = close(7)
return
;***
;*********************************************************
;
Had deze nog ergens liggen. Succes.....
[
Voor 0% gewijzigd door
ArCadE op 28-08-2002 15:33
. Reden: leesbaarheid..... ]