inspirednetworks
asked on
Logon Script - Group Conditional Section (WSF)
I have a logon script, and want to check for AD Group Membership and wrap a section of it in an if statement.
The idea obviously being that only members of that group have that section of the script applied to them.
The group name is "Teachers"
I have the whole script working right now, including the part that I want to work only for teachers, but it applies to everyone. I have removed sections of the script that I don't feel comfortable posting on the internet, so if certain variables aren't referenced properly that is why... keep in mind the script works perfectly right now other than the group conditional section not being conditional. I have marked very clearly where I need the group conditional section to be.
Your help is appreciated!
script.txt
The idea obviously being that only members of that group have that section of the script applied to them.
The group name is "Teachers"
I have the whole script working right now, including the part that I want to work only for teachers, but it applies to everyone. I have removed sections of the script that I don't feel comfortable posting on the internet, so if certain variables aren't referenced properly that is why... keep in mind the script works perfectly right now other than the group conditional section not being conditional. I have marked very clearly where I need the group conditional section to be.
Your help is appreciated!
script.txt
Hi, I am only posting the part about the Teachers here....you should be able to cut and paste bits to where you need it to go. The Function should go at the end of the code, and the declarations at the start.
Regards,
Rob.
Regards,
Rob.
' THIS LINE MUST BE PLACED IN THE MAIN CODE TO ALLOW THE DICTIONARY
' OBJECT TO REMAIN PERSISTENT FOR THE ISMEMBEROFGROUP FUNCTION
Dim objMemberships
Set objADSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objADSysInfo.UserName)
If IsMemberOfGroup(objUser, "Teachers") = True Then
objNetwork.MapNetworkDrive "W:", "\\dptsrv01\pt workgroups"
'Select Printers to be added
WshNetwork.AddWindowsPrinterConnection strPrinterPath10
WshNetwork.AddWindowsPrinterConnection strPrinterPath11
WshNetwork.AddWindowsPrinterConnection strPrinterPath12
'Select default printer using System Group Membership
'Membership according to proximity to printer
Dim grpfloor1, grpfloor2
Set grpfloor1 = GetObject("WinNT://DPT/Floor 1")
Set grpfloor2 = GetObject("WinNT://DPT/Floor 2")
If grpfloor1.IsMember(sADComputer) Then
WshNetwork.SetDefaultPrinter(strPrinterPath12)
End If
If grpfloor2.IsMember(sADComputer) Then
WshNetwork.SetDefaultPrinter(strPrinterPath10)
End If
End If
Function IsMemberOfGroup(objADUser, strGroupCN)
If IsEmpty(objMemberships) = True Then
Set objMemberships = CreateObject("Scripting.Dictionary")
objMemberships.Add LCase("ALL"), 0
If IsNull(objADUser.MemberOf) = False Then
If TypeName(objADUser.MemberOf) = "String" Then
objMemberships.Add LCase(Mid(Split(objADUser.MemberOf, ",")(0), 4)), 0
Else
For Each strGroupName In objADUser.MemberOf
objMemberships.Add LCase(Mid(Split(strGroupName, ",")(0), 4)), 0
Next
End If
End If
End If
If objMemberships.Exists(LCase(strGroupCN)) = True Then
IsMemberOfGroup = True
Else
IsMemberOfGroup = False
End If
End Function
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'!!!End If TEACGERS test here!!!!!!!!!!!!!!!!!!!!!!!!
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ASKER
Thanks, I will try to sort out, I'm useless at programming.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the grade.
Regards,
Rob.
Regards,
Rob.
ASKER
Thanks for your help!
http://www.rlmueller.net/IsMember1.htm
HTH,
exx