Ниже привожу логон скрипт в котором в зависимости от принадлежности к конкретной группе назначается сетевой диск причем во всех отдела диск будет с одинаковой буквой а папки на сервере у каждого отдела свои и подключаются при входе в домен
-
- Option Explicit
-
- Dim WshShell, WshNetwork
- Dim strUserDN, objSysInfo, GroupObj, UserGroups, UserObj
-
- UserGroups=""
-
-
- Set WshShell = WScript.CreateObject("WScript.Shell")
- Set objSysInfo = CreateObject("ADSystemInfo")
-
- strUserDN = objSysInfo.userName
-
- Set UserObj = GetObject("LDAP://" & strUserDN)
-
- For Each GroupObj In UserObj.Groups
- UserGroups=UserGroups & "[" & GroupObj.Name & "]"
- Next
-
-
- if InGroup("Отдел 1") Then
- MapDrv "R:", "\\srv02\xxxxx"
- end if
-
- if InGroup("Отдел кадров") Then
- MapDrv "R:", "\\srv02\xxxxxx"
- end if
-
- If InGroup("Торговый отдел") Then
- MapDrv "R:", "\\srv02\xxxxxxxx"
- end if
-
- If InGroup("Отдел 3") then
- MapDrv "R:", "\\srv02\xxxxxxxxxxxxxx"
- end if
-
- If InGroup("Podpiska") then
- MapDrv "P:", "\\srv02\aaaaaaa"
- MapDrv "R:", "\\srv02\zzzzzzzzzz"
- end if
-
-
- If InGroup("Бухгалтерия") then
- MapDrv "R:", "\\srv02\xxxxxxx"
- end if
-
-
- MapDrv "S:", "\\srv02\all"
-
-
-
-
- Function MapDrv(DrvLet, UNCPath)
-
- Dim WshNetwork,objFSO
- Dim Msg
-
- Set WshNetwork = WScript.CreateObject("WScript.Network")
- Set objFSO = CreateObject("Scripting.FileSystemObject")
-
- On Error Resume Next
-
- If objFSO.DriveExists(DrvLet) Then
- WshNetwork.RemoveNetworkDrive DrvLet, true, true
- End If
-
- WshNetwork.MapNetworkDrive DrvLet, UNCPath
-
- Select Case Err.Number
- Case 0
-
- Case -2147023694
- WshNetwork.RemoveNetworkDrive DrvLet, true, true
- WshNetwork.MapNetworkDrive DrvLet, UNCPath
-
- Case -2147024811
- WshNetwork.RemoveNetworkDrive DrvLet, true, true
- WshNetwork.MapNetworkDrive DrvLet, UNCPath
-
- Case Else
-
- Msg = "Mapping network drive error: " & _
- CStr(Err.Number) & " 0x" & Hex(Err.Number) & vbCrLf & _
- "Error description: " & Err.Description & vbCrLf
- Msg = Msg & "Domain: " & WshNetwork.UserDomain & vbCrLf
- Msg = Msg & "Computer Name: " & WshNetwork.ComputerName & vbCrLf
- Msg = Msg & "User Name: " & WshNetwork.UserName & vbCrLf & vbCrLf
- Msg = Msg & "Device name: " & DrvLet & vbCrLf
- Msg = Msg & "Map path: " & UNCPath
-
- WshShell.LogEvent 1, Msg, "\\srv01"
- End Select
- End Function
-
-
-
- Function InGroup(strGroup)
- InGroup=False
- If InStr(UserGroups,"[CN=" & strGroup & "]") Then
- InGroup=True
- End If
- End Function
Ответить
|