bdaboy22 0 Newbie Poster

I have a vbs script that is suppossed to look into AD and find any security group that follows the the format [map {drive letter} to {share name} on {server name}] and map a network drive for users that are a member. This is running in a Windows 2003 AD mixed-mode. It is not doing anything. The AD structure is:
Domain > Site > Policy Groups > Map E to share on server.

Here is the script:


'========================================================================== ====
'
'Drive mapping instructions:
'
' 1. The four default drives that need to be mapped for each user are:
'
' G: - Group public shares
' H: - User's home directory
' I: - User's Group's directory
' X: - Application directory
'
' 2. These four drives are mapped by a logon script - mapshare.vbs
'
' 3. The mapshare.vbs script reads the group membership of the
' logged on user. For each group:
'
' a) If a group is a Windows 2000 built-in group (Domain Admins,
' for example), the script does nothing.
'
' b) If a group is a GPO group (GPO groups begin with one of the
' following prefixes: cs-, cw-, ca-, us-, uw-, ua-), the
' script does nothing.
'
' c) If the group name takes the following form:
'
' map {drive letter} to {share name} on {server name}
'
' then the script attempts to map the appropriate resource.
' Note that the program recognizes only four variables for share
' names: %USERNAME%, %username%, %USERNAME%$, and %username%$
' and that combinations of upper and lower case do not work.
'
' d) If the group does not fall into one of the above categories,
' the script assumes that the group name is the name of a share
' on the user's home server and attempts to map the H: drive to
' this share. IF THE USER BELONGS TO MORE THAN ONE SUCH GROUP,
' THE SCRIPT HAS NO WAY OF DETERMINING WHICH GROUP IS CORRECT.
'
' 4. The mapshare.vbs script is itself run by a GPO:
'
' UC-WS-SC-Logon Script (mapshare.vbs)
'
' would be a GPO with the property:
'
' User Configuration | Windows Settings | Scripts (Logon/Logoff) | Logon
'
' set to:
'
' mapshare.vbs
'
'========================================================================== ====

Option Explicit

Dim g_oGroupDict
Dim g_oNet

Dim sAdsPath
Dim oUser
Dim oGroup
Dim sGroupName

Dim sOurDrive(23)
Dim iPosition
Dim sOurShare(23)
Dim sOurServer(23)
Dim iIndex
Dim iCount

iIndex = 0
iCount = 0
sGroupName = ""

On Error Resume Next

Set g_oNet = CreateObject("Wscript.Network")

If IsEmpty(g_oGroupDict) Then
Set g_oGroupDict = CreateObject("Scripting.Dictionary")
g_oGroupDict.CompareMode = vbTextCompare
sAdsPath = g_oNet.UserDomain & "/" & g_oNet.UserName
Set oUser = GetObject("WinNT://" & sAdsPath & ",user")

For Each oGroup In oUser.Groups

If (Left(oGroup.Name, 3) = "map") Then

sOurDrive(iIndex) = Mid(oGroup.Name, 5, 1) + ":"
iPosition = InStr(1, oGroup.Name, " on ", vbTextCompare)
sOurShare(iIndex) = Mid(oGroup.Name, 10, iPosition - 10)
sOurServer(iIndex) = Right(oGroup.Name, Len(oGroup.Name) - (iPosition + 3))

g_oNet.RemoveNetworkDrive sOurDrive, True, True
iIndex = iIndex + 1

ElseIf ((oGroup.Name <> "Administrators") And (oGroup.Name <> "Domain Users") And (Left(oGroup.Name, 2) <> "cs") And (Left(oGroup.Name, 2) <> "cw") And (Left(oGroup.Name, 2) <> "ca") And (Left(oGroup.Name, 2) <> "us") And (Left(oGroup.Name, 2) <> "uw") And (Left(oGroup.Name, 2) <> "ua")) Then

sGroupName = oGroup.Name

End If

Next

For iCount = 0 To (iIndex - 1)

If sOurShare(iCount) = "%USERNAME%$" Or sOurShare(iCount) = "%username%$" Then sOurShare(iCount) = oUser.Name & "$"
If sOurShare(iCount) = "%USERNAME%" Or sOurShare(iCount) = "%username%" Then sOurShare(iCount) = oUser.Name

If sOurShare(iCount) = "Group Share" Or sOurShare(iCount) = "group share" Then sOurShare(iCount) = sGroupName
g_oNet.RemoveNetworkDrive sOurDrive(iCount), True, True
g_oNet.MapNetworkDrive sOurDrive(iCount), "\\" & sOurServer(iCount) & "\" & sOurShare(iCount)

Next

End If