Announcement

Collapse
No announcement yet.

Creating network folders based on AD attributes

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating network folders based on AD attributes

    Hi,
    I'm trying to work out how to write a script (in whatever language) that will create a folder on a network location based on AD attributes when a user logs into a terminal server.

    so for example

    \\server1\datal\advariabledepartment\general\work folders\%username%


    eg.

    \\server1\data\marketing\general\work folders\auser

    or

    \\server1\data\executive\general\work folders\auser2

    Where both marketing and executive are pulled from the AD attribute of department and the username is taken from the username attribute.

    Thanks in advance!!

  • #2
    Re: Creating network folders based on AD attributes

    Try this VBScript (save as *.vbs file)

    Code:
    ' User Logon Script
    
    DIM oFSO, objUser
    
    ' Currently logged in User
    Set objSysInfo = CreateObject("ADSystemInfo")
    Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
    strUserDept = objUser.department
    strUserName = objUser.SAMAccountName
    
    ' create folder structure
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    strFolder = "\\server1\data\" & strUserDept & "\general\work folders\" & strUserName & "\"
    MKDIR strFolder
    
    
    ' subroutine to build tree
    Sub MKDIR(ByVal sPath)
       If Not oFSO.FolderExists(sPath) Then
         mkdir oFSO.GetParentFolderName(sPath)
         oFSO.CreateFolder sPath
       End If
    End Sub
    /Rems

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment

    Working...
    X