Quantcast
Channel: Software Communities : Popular Discussions - ActiveRoles
Viewing all articles
Browse latest Browse all 1277

Problems setting folder rights at user creation

$
0
0
Hi, sorry for all the threads lately, I'm trying to wrap up the last bits of the setup of a client here. And I'm really scratching my head here on a script execution which sets folder permissions of the users home folder.

The thing is, I can't use the build in home folder generation because we have a huge SAN where the users home folder's physical location is based on the users location.
This is to reduce network traffic and have the home folder be on the server which is geographical closest to the user.

So, I've got this script which, based on the value selected from ExtensionAttribute1, determines which server the home folder is created on.

The thing is, everything works fine at "onPreModify" and at "onPostModify"
But trying to get it to work with "onPreCreate" or "OnPostCreate" is a real pain!

And only a portion of the script doesn't seem to work. First, the script creates the home folder based on location. And this does work as intended. But setting the folder rights, this is where the problems are.

At first, I used xcacls.exe to set the permissions. And this worked as intended during said event handlers. But trying to get it to work during "onPostCreate" or "onPreCreate" was a strange affair. Sometimes (without modifying the script at all) some permissions were set. Other times, none were set. And sometimes, the permissions was set correctly. Very strange indeed.

So I thought it could have to do with xcacls.exe, so I tried using SetACL.exe instead. The same thing happens here as well. Everything works with said Event handlers. But during user creation, no sir.

Here's the code, I could really use some help here because this is driving me insane!

[code]
Sub onPreCreate(Request)

If (LCase(Request.Class) <> "user") Then Exit Sub
Dim Lokasjon, username, strHomeServer

Set WshShell =CreateObject("WScript.Shell")

'username = CStr(Request.Get("samAccountName"))
'username = DirObj.Get("samAccountName")
username = CStr(Request.Get("samAccountName"))
Lokasjon = CStr(Request.Get("extensionAttribute1"))


Set objNetwork = CreateObject("WScript.Network")
Set oFS = CreateObject("Scripting.FileSystemObject")

' Sjekk hvilken lokasjon som er valgt
If Lokasjon = "City1" Then
Filserver = "\\fileserver\ikt\"
End If
If Lokasjon = "City2" Then
Filserver = "\\fileserver2\ikt\"
End If

oFS.CreateFolder(Filserver & username)

Dim strRemoveRights, strRunUsersRights

strRunUsersRights = "%COMSPEC% /c C:\CustomScripts\SetACL.vbs "&Filserver&Username &" " & "domaingrp\"&Username


WshShell.Run (strRunUsersRights) ' Adds users's rights
'WshShell.Run (strRunAdminRights) ' Adds Admins's rights

' Lager DFS

Dim strDFS

strDFS = "%comspec% /C dfscmd.exe /map \\domain.no\Users\" & Username & " " & Fileserver & Username
WshShell.Run (strDFS)




End Sub

'***************************************************************************
' FUNKSJONER LEGGES HER, IKKE RØR '***************************************************************************

Function IsAttributeModified (ByVal strAttributeName, ByRef Request)
Dim objEntry, nControlCode, boolResult

IsAttributeModified = False

Set objEntry = Request.GetPropertyItem(strAttributeName, ADSTYPE_CASE_IGNORE_STRING)

If (objEntry Is Nothing) Then Exit Function
If (objEntry.ControlCode = 0) Then Exit Function

IsAttributeModified = True
End Function '-- IsAttributeModified


Function IsGroupPresent (ByVal arrGroups, ByVal strGroup)
IsGroupPresent = False
For Each strMemberOf In arrGroups
' Eventlog.ReportEvent 0," verdi av strMemberOf = " & strMemberOf
If strMemberOf = strGroup Then
IsGroupPresent = True
End If
' Eventlog.ReportEvent 0,"IsGroupPresent = " & IsGroupPresent
Next
End Function

Function IsObjectClassRequested(ByVal strClassName, ByRef Request)
IsObjectClassRequested = (LCase(Request.Class) = LCase(strClassName))
End Function[/code]

Viewing all articles
Browse latest Browse all 1277

Trending Articles