Re: What's wrong here

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Al Dunbar [MS-MVP] (alan-no-drub-spam_at_hotmail.com)
Date: 12/24/04


Date: Fri, 24 Dec 2004 16:30:16 -0700


"Ole Rasmussen" <ole@tera-sat.com> wrote in message
news:eXdCvcb6EHA.2156@TK2MSFTNGP10.phx.gbl...
> 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????

Not sure, but it could be that cacls wants a fully qualified username, i.e.

wshShell.Run "cacls \\mail\brugere\" & sUserName _
    & " /T /E /G " _
    & "mydomain\" & sUserName _
    & ":C", 1, True--

Either that, or you have some DC replication issues to deal with.

/Al

> --------------------------------------------------------------------------
--------------------------
> '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
>
>
>
>
>
>
>
>
>
>
>
>



Relevant Pages

  • Whats wrong here
    ... I made this little script to create user, homedir and set permissions on the ... Dim RootDSE ... Dim iInput ... user.Put "samAccountName", sUserName ...
    (microsoft.public.scripting.vbscript)
  • Some or all identity references could not be translated.
    ... at System.Security.AccessControl.CommonObjectSecurity.ModifyAccess(AccessControlModification modification, AccessRule rule, Boolean& modified) ... If I try set permissions for same user/group about 30 seconds after creation everything went fine. ... Dim dInfo As New DirectoryInfo ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • RE: Delete Certain Rows Based on User Input
    ... Dim sUsername As String ... Dim sPrompt As String ... Dim myrange, MyRange1 As Range ...
    (microsoft.public.excel.programming)
  • Re: Running under Scheduler
    ... "GetUserNameA" (ByVal lpBuffer As String, ... Public Function SystemUserName() ... Dim m_Val As Long ... dim sUSERname as string ...
    (microsoft.public.vb.general.discussion)
  • Re: Adding Options When User Cancels/Cannot Find
    ... Dim sUsername As String ... Dim sPrompt As String ... MsgBox "Unable to find " & sUsername ...
    (microsoft.public.excel.programming)