[gptalk] Sanity Check on login script
- From: <Booker.Washington@xxxxxxxxxxxxxx>
- To: <gptalk@xxxxxxxxxxxxx>
- Date: Mon, 15 Dec 2008 16:27:19 -0500
On the script below, do you see any occasion, where a user would randomly get
the drive letter e showing up as disconnected drive under Network Drives?
Seemingly, once I put this script in a GPO, some users have said or noticed
that occasionally the Drive letter e, will show as a disconnected network
drive, usually with no path, sometimes with the
'nasstorage.mountedshare.com\com' showing as the path to the drive
I don't see where anything below would contribute to that, but I wanted to make
sure I was not missing anything
Option Explicit
Dim objSysInfo, objNetwork, strUserPath, objUser
Dim adoCommand, adoConnection, strBase, strAttributes
Dim objGroupList
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
'Removes curent mappings
On Error Resume Next
objNetwork.RemoveNetworkDrive "L:", True, True
objNetwork.RemoveNetworkDrive "J:", True, True
objNetwork.RemoveNetworkDrive "Z:", True, True
objNetwork.RemoveNetworkDrive "R:", True, True
objNetwork.RemoveNetworkDrive "N:", True, True
objNetwork.RemoveNetworkDrive "O:", True, True
objNetwork.RemoveNetworkDrive "U:", True, True
objNetwork.RemoveNetworkDrive "S:", True, True
objNetwork.RemoveNetworkDrive "M:", True, True
objNetwork.RemoveNetworkDrive "I:", True, True
objNetwork.RemoveNetworkDrive "K:", True, True
objNetwork.RemoveNetworkDrive "X:", True, True
objNetwork.RemoveNetworkDrive "Y:", True, True
objNetwork.RemoveNetworkDrive "Q:", True, True
objNetwork.RemoveNetworkDrive "P:", True, True
objNetwork.RemoveNetworkDrive "V:", True, True
On Error GoTo 0
Wscript.Sleep(5000)
If (IsMember(objUser, "nas IT Services Group") = True) Then
objNetwork.MapNetworkDrive "Y:", _
"\\nasstorage.mountedshare.com\com\shares\groups\IT services", False
End If
If (IsMember(objUser, "nas Career Services") = True) Then
objNetwork.MapNetworkDrive "L:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Career Services", False
objNetwork.MapNetworkDrive "J:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Career Svcs_Act", False
objNetwork.MapNetworkDrive "Z:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Undergraduate Office", False
End If
If (IsMember(objUser, "nas Career Services SAs") = True) Then
objNetwork.MapNetworkDrive "L:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Career Services", False
objNetwork.MapNetworkDrive "J:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Career Svcs_Act", False
End If
If (IsMember(objUser, "nas CIBER") = True) Then
objNetwork.MapNetworkDrive "R:", _
"\\nasstorage.mountedshare.com\com\shares\groups\CIBER", False
End If
If (IsMember(objUser, "nas Communications") = True) Then
objNetwork.MapNetworkDrive "R:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Communications", False
objNetwork.MapNetworkDrive "N:", _
"\\nasstorage.mountedshare.com\com\shares\groups\DeanSuite", False
End If
If (IsMember(objUser, "nas Communications Share Guest access") = True) Then
objNetwork.MapNetworkDrive "V:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Communications", False
End If
If (IsMember(objUser, "nas Dean Suite non HR") = True) Then
objNetwork.MapNetworkDrive "L:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Building Operations", False
objNetwork.MapNetworkDrive "N:", _
"\\nasstorage.mountedshare.com\com\shares\groups\DeanSuite", False
objNetwork.MapNetworkDrive "O:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Accounting", False
End If
If (IsMember(objUser, "nas Development") = True) Then
objNetwork.MapNetworkDrive "L:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Development", False
objNetwork.MapNetworkDrive "R:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Communications", False
objNetwork.MapNetworkDrive "M:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Development\Student Share",
False
objNetwork.MapNetworkDrive "N:", _
"\\nasstorage.mountedshare.com\com\shares\groups\DeanSuite", False
End If
If (IsMember(objUser, "nas Development SAs") = True) Then
objNetwork.MapNetworkDrive "M:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Development\Student Share",
False
End If
If (IsMember(objUser, "nas Eview Users") = True) Then
objNetwork.MapNetworkDrive "Y:", _
"\\nasstorage.mountedshare.com\com\shares\groups\EVIEW", False
End If
If (IsMember(objUser, "nas Executive Masters") = True) Then
objNetwork.MapNetworkDrive "I:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Executive Education", False
objNetwork.MapNetworkDrive "J:", _
"\\nasstorage.mountedshare.com\com\shares\groups\EMSMOT_Act", False
objNetwork.MapNetworkDrive "K:", _
"\\nasstorage.mountedshare.com\com\shares\groups\EMSMOT", False
objNetwork.MapNetworkDrive "P:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Accounting", False
objNetwork.MapNetworkDrive "L:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Executive Programs", False
End If
If (IsMember(objUser, "nas Executive Programs") = True) Then
objNetwork.MapNetworkDrive "I:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Executive Education", False
objNetwork.MapNetworkDrive "J:", _
"\\nasstorage.mountedshare.com\com\shares\groups\EMSMOT_Act", False
objNetwork.MapNetworkDrive "K:", _
"\\nasstorage.mountedshare.com\com\shares\groups\EMSMOT", False
objNetwork.MapNetworkDrive "P:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Accounting", False
objNetwork.MapNetworkDrive "L:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Executive Programs", False
End If
If (IsMember(objUser, "nas Explab Share participants") = True) Then
objNetwork.MapNetworkDrive "Z:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Explab", False
End If
If (IsMember(objUser, "nas FACS Admin Assistant read access") = True) Then
objNetwork.MapNetworkDrive "S:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Accounting\FAcS", False
End If
If (IsMember(objUser, "nas Graduate Office") = True) Then
objNetwork.MapNetworkDrive "M:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Graduate Office", False
End If
If (IsMember(objUser, "nas Grad Assistant Share") = True) Then
objNetwork.MapNetworkDrive "U:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Graduate Assistantship", False
End If
If (IsMember(objUser, "nas HR staff") = True) Then
objNetwork.MapNetworkDrive "X:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Building Operations", False
objNetwork.MapNetworkDrive "N:", _
"\\nasstorage.mountedshare.com\com\shares\groups\DeanSuite", False
objNetwork.MapNetworkDrive "O:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Accounting", False
objNetwork.MapNetworkDrive "Y:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Communications", False
objNetwork.MapNetworkDrive "R:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Human Resources", False
objNetwork.MapNetworkDrive "Q:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Accounting\PCard", False
End If
If (IsMember(objUser, "ILE Office") = True) Then
objNetwork.MapNetworkDrive "J:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Institute for LE", False
End If
If (IsMember(objUser, "ILE GRAs") = True) Then
objNetwork.MapNetworkDrive "J:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Institute for LE", False
End If
If (IsMember(objUser, "nas Tiger Share participants") = True) Then
objNetwork.MapNetworkDrive "R:", _
"\\nasstorage.mountedshare.com\com\shares\groups\TIGER", False
End If
If (IsMember(objUser, "nas Undergraduate Office") = True) Then
objNetwork.MapNetworkDrive "M:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Undergraduate Office", False
End If
If (IsMember(objUser, "nas Recruiting Share Access") = True) Then
objNetwork.MapNetworkDrive "Q:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Recruiting", False
End If
If (IsMember(objUser, "nas Faculty") = True) Then
objNetwork.MapNetworkDrive "S:", _
"\\nasstorage.mountedshare.com\com\shares\groups\Accounting\FAcS", False
End If
Function IsMember(ByVal objADObject, ByVal strGroupNTName)
' Function to test for group membership.
' objADObject is a user or computer object.
' strGroupNTName is the NT name (sAMAccountName) of the group to test.
' objGroupList is a dictionary object, with global scope.
' Returns True if the user or computer is a member of the group.
' Subroutine LoadGroups is called once for each different objADObject.
Dim objRootDSE, strDNSDomain
' The first time IsMember is called, setup the dictionary object
' and objects required for ADO.
If (IsEmpty(objGroupList) = True) Then
Set objGroupList = CreateObject("Scripting.Dictionary")
objGroupList.CompareMode = vbTextCompare
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
' Search entire domain.
strBase = "<LDAP://" & strDNSDomain & ">"
' Retrieve NT name of each group.
strAttributes = "sAMAccountName"
' Load group memberships for this user or computer into dictionary
' object.
Call LoadGroups(objADObject)
Set objRootDSE = Nothing
End If
If (objGroupList.Exists(objADObject.sAMAccountName & "\") = False) Then
' Dictionary object established, but group memberships for this
' user or computer must be added.
Call LoadGroups(objADObject)
End If
' Return True if this user or computer is a member of the group.
IsMember = objGroupList.Exists(objADObject.sAMAccountName & "\" _
& strGroupNTName)
End Function
Sub LoadGroups(ByVal objADObject)
' Subroutine to populate dictionary object with group memberships.
' objGroupList is a dictionary object, with global scope. It keeps track
' of group memberships for each user or computer separately. ADO is used
' to retrieve the name of the group corresponding to each objectSid in
' the tokenGroup array. Based on an idea by Joe Kaplan.
Dim arrbytGroups, k, strFilter, adoRecordset, strGroupName, strQuery
' Add user name to dictionary object, so LoadGroups need only be
' called once for each user or computer.
objGroupList.Add objADObject.sAMAccountName & "\", True
' Retrieve tokenGroups array, a calculated attribute.
objADObject.GetInfoEx Array("tokenGroups"), 0
arrbytGroups = objADObject.Get("tokenGroups")
' Create a filter to search for groups with objectSid equal to each
' value in tokenGroups array.
strFilter = "(|"
If (TypeName(arrbytGroups) = "Byte()") Then
' tokenGroups has one entry.
strFilter = strFilter & "(objectSid=" _
& OctetToHexStr(arrbytGroups) & ")"
ElseIf (UBound(arrbytGroups) > -1) Then
' TokenGroups is an array of two or more objectSid's.
For k = 0 To UBound(arrbytGroups)
strFilter = strFilter & "(objectSid=" _
& OctetToHexStr(arrbytGroups(k)) & ")"
Next
Else
' tokenGroups has no objectSid's.
Exit Sub
End If
strFilter = strFilter & ")"
' Use ADO to search for groups whose objectSid matches any of the
' tokenGroups values for this user or computer.
strQuery = strBase & ";" & strFilter & ";" _
& strAttributes & ";subtree"
adoCommand.CommandText = strQuery
Set adoRecordset = adoCommand.Execute
' Enumerate groups and add NT name to dictionary object.
Do Until adoRecordset.EOF
strGroupName = adoRecordset.Fields("sAMAccountName").Value
objGroupList.Add objADObject.sAMAccountName & "\" _
& strGroupName, True
adoRecordset.MoveNext
Loop
adoRecordset.Close
Set adoRecordset = Nothing
End Sub
Function OctetToHexStr(ByVal arrbytOctet)
' Function to convert OctetString (byte array) to Hex string,
' with bytes delimited by \ for an ADO filter.
Dim k
OctetToHexStr = ""
For k = 1 To Lenb(arrbytOctet)
OctetToHexStr = OctetToHexStr & "\" _
& Right("0" & Hex(Ascb(Midb(arrbytOctet, k, 1))), 2)
Next
End Function
Booker T. Washington III
Systems Support Specialist
Other related posts:
- » [gptalk] Sanity Check on login script - Booker.Washington