What's wrong here
From: Ole Rasmussen (ole_at_tera-sat.com)
Date: 12/24/04
- Next message: Bob Barrows [MVP]: "Re: Finding block begin/end in VBScript"
- Previous message: Bob Barrows [MVP]: "Re: Creating a VBScript to execute .SQL file"
- Next in thread: Al Dunbar [MS-MVP]: "Re: What's wrong here"
- Reply: Al Dunbar [MS-MVP]: "Re: What's wrong here"
- Reply: Clay Calvert: "Re: What's wrong here"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 24 Dec 2004 13:59:42 +0100
I made this little script to create user, homedir and set permissions on the
dir, but I can't get it to set permissions for the user, everything else
works fine. I have tryed moving the line
--wshShell.Run "cacls \\mail\brugere\" & sUserName & " /T /E /G " &
sUserName & ":C", 1, True--
both before and after the --User.Setinfo-- but nothing helps, WHAT the heck
is wrong????
----------------------------------------------------------------------------------------------------
'adduser.vbs - Create user in OU + homedir + homedir rights.
Dim RootDSE
Dim ouHO
Dim sFirstName, sLastName, sUserName, sPromt, sAdresse, sPostnr, sBy, sTlf
Dim iInput
Dim user
Dim ou
Dim ounavn
Dim fso, wshShell
Dim fldUserHomedir
ounavn = InputBox("Organizational Unit?", "Skriv OU")
ou = "OU=" + ounavn
Set fso = CreateObject("Scripting.FileSystemObject")
Set wshShell = WScript.CreateObject("Wscript.Shell")
Set RootDSE = GetObject ("LDAP://RootDSE")
Set ouHO = GetObject ("LDAP://" + ou + "," &
RootDSE.get("DefaultNamingContext"))
Do
sFirstName = InputBox("Fornavn ?", "Fornavn")
sLastName = InputBox("Efternavn ?", "Efternavn")
sAdresse = InputBox("Adresse ?", "Adresse")
sPostnr = InputBox("Postnr ?", "Postnr")
sBy = InputBox("By ?", "By")
sTlf = InputBox("Telefon ?", "Telefon")
sUserName = LCase(Left(sFirstName, 1) & sLastName)
sPromt = "Ny bruger " & sFirstName & " " & sLastName & Chr(10) & "med
brugernavn " & sUserName & "?"
iInput = MsgBox(sPromt, vbYesNo, "bekræft bruger")
if iInput = vbYes then
Set user = ouHO.Create( "User" , "CN=" & sFirstName & " " & sLastName)
user.Put "samAccountName" , sUserName
user.Put "givenName" , sFirstName
user.Put "sn" , sLastName
user.Put "userPrincipalName" , sUserName
user.Put "streetAddress" , sAdresse
user.Put "PostalCode" , sPostnr
User.put "l", sBy
User.put "telephoneNumber", sTlf
user.put "HomeDirectory", "\\mail\brugere\" & sUserName
'Create user home directory.
If Not fso.FolderExists("\\mail\brugere\" & sUserName) Then
Set fldUserHomedir = fso.CreateFolder("\\mail\brugere\" & sUserName)
End If
'Set full rights for Administrators and change right for user and removes
the Everyone group
wshShell.Run "net share " & sUserName & "=f:\brugere\" & sUserName & "
/y", 1, True
wshShell.Run "cacls \\mail\brugere\" & sUserName & " /T /E /G
Administrator:F", 1, True
wshShell.Run "cacls \\mail\brugere\" & sUserName & " /T /E /R everyone",
1, True
wshShell.Run "cacls \\mail\brugere\" & sUserName & " /T /E /G " &
sUserName & ":C", 1, True
User.put "scriptPath", "logon.vbs"
User.SetInfo
user.SetPassword "12345"
wscript.echo "bruger oprettet."
else
wscript.echo "bruger ikke oprettet."
end if
Loop While msgBox("opret ny bruger ?" , vbYesNo, "Question") = vbYes
wscript.echo "Dette afslutter scriptet." & Chr(10) & "Click ok for at
afslutte."
----------------------------------------------------------------------------------------------------
Regards,
Ole Rasmussen
- Next message: Bob Barrows [MVP]: "Re: Finding block begin/end in VBScript"
- Previous message: Bob Barrows [MVP]: "Re: Creating a VBScript to execute .SQL file"
- Next in thread: Al Dunbar [MS-MVP]: "Re: What's wrong here"
- Reply: Al Dunbar [MS-MVP]: "Re: What's wrong here"
- Reply: Clay Calvert: "Re: What's wrong here"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|