Solved

# Windows 2008 VB logon script map drive by group membership

Posted on 2013-01-04
Medium Priority
542 Views
Hello,

I used a basic VB script I found on a microsoft site.  The home directory part is working but the group membership mappings are not working. If anyone can tell me what Im doing wrong id appreciate it.  Here is the script I used:

Const Finance_GROUP     = "cn=SG_Finance"
Const IT_GROUP          = "CN=SG_IT"

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "h:","\\njfile\us$\" & wshNetwork.UserName Set adSysInfo = CreateObject("ADSystemInfo") Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName) strGroups = LCase(Join(CurrentUser.MemberOf)) If InStr(strGroups, finance_GROUP) Then wshNetwork.MapNetworkDrive "J:","\\njfile\finance" ElseIf InStr(strGroups, IT_GROUP) Then wshNetwork.MapNetworkDrive "J:","\\njfile\it$\"

End If
0
Question by:serverbob

LVL 17

Accepted Solution

Kent Dyer earned 384 total points
ID: 38745190
I think is more what you are looking for..
http://technet.microsoft.com/en-us/magazine/2006.03.scriptingguy.aspx

HTH,

Kent
0

LVL 11

Assisted Solution

netballi earned 192 total points
ID: 38745222
Very simple the line

"strGroups = LCase(Join(CurrentUser.MemberOf))"

StrGroups is a array value and you should be spliting the array into its different value like

StrGroups(0), StrGroups(1)......and so on and check for the appropriate group.
0

LVL 17

Assisted Solution

Kent Dyer earned 384 total points
ID: 38745234
0

LVL 32

Assisted Solution

Robberbaron (robr) earned 189 total points
ID: 38747560
the scipt itself looks ok as the Join function merges all the array elements of CurrentUser.MemberOf into a single string.

Wscript.echo strgroups

after the line that creates StrGroups to check what it's value is. ?

May need to check that it is not empty as well.

the link provided by kent shows a different object used to get membership.
as does this... which i know works.
' ****************************************************************************
**********************

function InGroup(sGroup)
on error resume next
'Checking to see if user is in " & sGroup & " group")

set oDomGrp = GetObject("WinNT://" & sNTDomain & "/" & sGroup)

InGroup = false

if oDomGrp.isMember("WinNT://" & sNTDomain & "/" & sUserName) then
InGroup = true
else
InGroup = false
end if
end function

0

Author Closing Comment

ID: 38754573
Thanks everyone.  Got it working!
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A safe way to clean winsxs folder from your windows server 2008 R2 editions
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
###### Suggested Courses
Course of the Month16 days, 11 hours left to enroll