I have a script which maps drives and creates or maps to the users personal folder. We have 2 sites one in Warwick and another in Basildon.
I want to be able to map the users personal folder according to the site they are from (I.e. Warwick, Basildon) as the user folder are located on different servers.
So if a person from Warwick was in Basildon then I would want there personal user folder to be mapped to Warwick server and vice versa. Any ideas how this could be achieved?
At present all users are part of a group (I.e. IT, Sales etc) in active directory. The only way to tell whether they belong to Warwick or Basildon is by Email User Groups.
I want to be able to map the users personal folder according to the site they are from (I.e. Warwick, Basildon) as the user folder are located on different servers.
So if a person from Warwick was in Basildon then I would want there personal user folder to be mapped to Warwick server and vice versa. Any ideas how this could be achieved?
At present all users are part of a group (I.e. IT, Sales etc) in active directory. The only way to tell whether they belong to Warwick or Basildon is by Email User Groups.
Code:
'On Error Resume Next
Dim WSHShell, WSHNetwork, objDomain, DomainString, UName, UserObj
Dim Path, strComputer, objFSO, objFolder
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
' Create FileSystemObject. So the createFolder method can be appllied .
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Automatically find the domain name
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")
'Find the Windows Directory
WinDir = WSHShell.ExpandEnvironmentStrings("%WinDir%")
'Get the user name
UName = WSHNetwork.UserName
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UName)
'Get the computer name for use in add-on code later
strComputer = WSHNetwork.ComputerName
For Each GroupObj In UserObj.Groups
Select Case (GroupObj.Name)
Case "IT"
if objFSO.FolderExists("\\Server\Users\" & Uname ) = False then
set objFolder = objFSO.CreateFolder("\\Server\Users\" & Uname)
WSHNetwork.MapNetworkDrive "U:", "\\Server\Users\" & Uname
Else
WSHNetwork.MapNetworkDrive "U:", "\\Server\Users\" & Uname
end If
WSHNetwork.MapNetworkDrive "L:", "\\Server\server"
WSHNetwork.MapNetworkDrive "T:", "\\Server\server"
End Select
Next
'Clean Up Memory
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing
'Quit the Script
wscript.quit