Link to home
Start Free TrialLog in
Avatar of dudure
dudure

asked on

How to map a drive & create folder based on AD Group membership

hi ,
i write a script that map a network drive base based on AD Group membership
i want to add the option to create a folder to the based on AD Group membership and to give the user full control on the folder .

Exmple : if a user belong to DPCtxBakara_Group it will create him the folder on this path : \\Servername\dfs$\citrix\danpt\home\" _ & objNetwork.UserName and give him full control
and if the user belong to DRCtxBakara_Group it will create him the folder on this path : \\Servername\dfs$\citrix\danpt\home\" _ _ & objNetwork.UserName and give him full control

i also want to check if already have a folder and if he have only map io and exit from the script .

the script :


Option Explicit
Dim objNetwork, objUser, CurrentUser  
Dim strGroup


Const DPCtxBakara_Group = "cn=DPCtxBakara"
Const DRCtxBakara_Group = "cn=DRCtxBakara"
Const HFCtxBakara_Group = "cn=HFCtxBakara"
Const JRCtxBakara_Group = "cn=JRCtxBakara"
Const MRCtxBakara_Group = "cn=MRCtxBakara"
Const SHCtxBakara_Group = "cn=SHCtxBakara"
Const TACtxBakara_Group = "cn=TACtxBakara"
Const ZACtxBakara_Group = "cn=ZACtxBakara"


Set objNetwork = CreateObject("WScript.Network")
Set objUser = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & objUser.UserName)
strGroup = LCase(Join(CurrentUser.MemberOf))

If InStr(strGroup, lcase(DPCtxBakara_Group)) Then
WScript.Echo "DPCtxBakara "
objNetwork.MapNetworkDrive "w:", "\\Servername\dfs$\citrix\danpt\home\" _
& objNetwork.UserName

ElseIf InStr(strGroup, lcase(DRCtxBakara_Group)) Then
WScript.Echo "DPCtxBakara "
objNetwork.MapNetworkDrive "w:", "\\Servername\dfs$\citrix\darom\home\" _
& objNetwork.UserName

ElseIf InStr(strGroup, lcase(HFCtxBakara_Group)) Then
WScript.Echo " HFCtxBakara " 
objNetwork.MapNetworkDrive "w:", "\\Servername\dfs$\citrix\haifa\home\"_
& objNetwork.UserName

ElseIf InStr(strGroup, lcase(JRCtxBakara_Group)) Then
WScript.Echo " JRCtxBakara " 
objNetwork.MapNetworkDrive "w:", "\\Servername\dfs$\citrix\jerusalem\home\"_
& objNetwork.UserName

ElseIf InStr(strGroup, lcase(MRCtxBakara_Group)) Then
WScript.Echo " MRCtxBakara " 
objNetwork.MapNetworkDrive "w:", "\\Servername\dfs$\citrix\merkaz\home\"_
& objNetwork.UserName

ElseIf InStr(strGroup, lcase(SHCtxBakara_Group)) Then
WScript.Echo " SHCtxBakara " 
objNetwork.MapNetworkDrive "w:", "\\Servername\dfs$\citrix\shosh\home\"_
& objNetwork.UserName

ElseIf InStr(strGroup, lcase(TACtxBakara_Group)) Then
WScript.Echo " TACtxBakara " 
objNetwork.MapNetworkDrive "w:", "\\Servername\dfs$\citrix\tayf\home\"_
& objNetwork.UserName

ElseIf InStr(strGroup, lcase(ZACtxBakara_Group)) Then
WScript.Echo " ZACtxBakara " 
objNetwork.MapNetworkDrive "w:", "\\Servername\dfs$\citrix\zafon\home\"_
& objNetwork.UserName


End If
Wscript.Echo "Finished mapping Groups - check drives "
WScript.Quit


ASKER CERTIFIED SOLUTION
Avatar of Serge Fournier
Serge Fournier
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial