IfMember.exe

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Does anyone have a good example or location of where ican
find how to use ifMember to map network drives using WSH
or VBS?
 
Mark

Below is an example of an 'IfMember' login script I use. Have a look and
let me know what you think...

'---------------------------------------------------------------------
'Author Steve Linger

'Script_Type vbscript

'Sub_Type LogonScripts

'Comment

'Login script that will map the J: drives based on NT group membership,
'the M: drive to \\Server\shared, and the L: drive \\server\user\%username

'Script
'--------------------------------------------------------------------
'
'Program Name London.VBS
'
'Author Steve Linger
'
'Description VBS Login Script for xxxx domain
'
'Design
'
'Edit History 17/07/02 Original

'--------------------------------------------------------------------
'declare global variables here
Option Explicit

Dim oShell, oNet, oFSO, oWshNetwork, oGroupDict

'--------------------------------------------------------------------
'declare Objects here

Set oShell = CreateObject("Wscript.Shell")
Set oNet = CreateObject("Wscript.Network")
set oFSO = CreateObject("Scripting.FileSystemObject")

'--------------------------------------------------------------------
On error resume next
'all mapping and stuff is done from
here


oNet.RemoveNetworkDrive "J:"
oNet.RemoveNetworkDrive "L:"
oNet.RemoveNetworkDrive "M:" 'this line deletes the mappings

oNet.MapNetworkDrive "L:", "\\server\user$\" & oNet.UserName

oNet.MapNetworkDrive "M:", "\\server\shared" 'this line can be used
to map any static drive

If IsMember("group1") Then
oNet.MapNetworkDrive "j:", "\\server\department\folder1"
ElseIf IsMember("group2") Then
oNet.MapNetworkDrive "j:", "\\server\department\folder2"
ElseIf IsMember("group3") Then
oNet.MapNetworkDrive "j:", "\\server\department\folder3"
Else
oNet.MapNetworkDrive "j:", "\\server\department"
End If

'--------------------------------------------------------------------
'find out what groups the user
belongs too
Function IsMember(sGroup)
Dim sAdsPath, oUser, oGroup

If IsEmpty(oGroupDict) Then
Set oGroupDict = CreateObject("Scripting.Dictionary")
oGroupDict.CompareMode = vbTextCompare

sAdsPath = oNet.UserDomain & "/" & oNet.UserName
Set oUser = GetObject("WinNT://" & sAdsPath & ",user")

For Each oGroup In oUser.Groups
oGroupDict.Add oGroup.Name, "-"
Next

Set oUser = Nothing
End If

IsMember = CBool(oGroupDict.Exists(sGroup))

End Function

Regards

Steve
 
Back
Top