Solved

Windows 2008 VB logon script map drive by group membership

Posted on 2013-01-04
5
528 Views
Last Modified: 2013-01-08
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
Comment
Question by:serverbob
5 Comments
 
LVL 17

Accepted Solution

by:
Kent Dyer earned 128 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

by:netballi
netballi earned 64 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

by:Kent Dyer
Kent Dyer earned 128 total points
ID: 38745234
0
 
LVL 32

Assisted Solution

by:Robberbaron (robr)
Robberbaron (robr) earned 63 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.

Can you add
Wscript.echo strgroups 

Open in new window

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

Open in new window

0
 

Author Closing Comment

by:serverbob
ID: 38754573
Thanks everyone.  Got it working!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

I was supporting a handful of Windows 2008 (non-R2) 2 node clusters with shared quorum disks. Some had SQL 2008 installed and some were just a vendor application that we supported. For the purposes of this article it doesn’t really matter which so w…
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now