|
-
Oct 15th, 2009, 06:41 AM
#1
Thread Starter
New Member
networkdrives
Hello!
First i would like to say sorry for my "not-so-good english". Please ask if you dont understand what im trying to write
I am very new to VB. I am trying to make a login script in VB that maps different networkdrives based on what group (security group in AD) the user is a member of. I have written a little bit. But it doesnt work as i want it to.
It looks something like this:
Code:
Option Explicit
Const STAFF = "cn=staff"
Const STUDENTS = "cn=students"
Dim wshNetwork, CurrentUser, strGroups
Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))
'STAFF
If InStr(strGroups, STAFF) Then
wshNetwork.MapNetworkDrive "J:", "\\SERVER\Shared\"
wshNetwork.MapNetworkDrive "I:", "\\SERVER\Shared\"
End If
'STUDENTS
ElseIf InStr(strGroups, STUDENTS Then
wshNetwork.MapNetworkDrive "I:", "\\SERVERl\Shared\"
End If
I found a version af this when i searched on google and i changed it to match my server and folders. But i must have made some misstake because it doesnt work.
Also the security group named STAFF includes 2 other security groups. One of thoose groups should only get "I:" mapped. I assumed that will happen automaticly since that group doesnt have any rights to "J:"..?
Is it at all possible to do all this in one script? I read that you could also do 2 scripts for this. But i thought makeing one would be easier.
I hope you understand. And please ask if there is any other information needed to solve this.
Thanks! xoxo Lisa.
-
Oct 15th, 2009, 07:41 AM
#2
Re: networkdrives
Welcome to the forums. 
When you say it doesn't work, what do you mean? Are you getting errors?
-
Oct 15th, 2009, 08:12 AM
#3
Re: networkdrives
While debugging the script you may want to put a message box after you join the groups and see what the value is. I think the list would come in as staff,student. You are then doing in InStr check looking for cn=staff and cn=student. I don't think that will ever match. Try changing the constances and give it a try again.
Const STAFF = "staff"
Const STUDENTS = "students"
-
Oct 15th, 2009, 09:08 AM
#4
Thread Starter
New Member
Re: networkdrives
Thanks for the replys. Im not at work at the moment and i dont have access to the server from here. So i don't remember the error codes i got. But i do remember one problem.
There are 2 groups that are members of Staff. When logging in with the group that should have both drives mapped it seems to work. But when logging in with the other group (still under staff) none of the drives get mapped.
I will post more details tomorrow when im at work so i can test it properly. But yeah im pretty new at this stuff so maybe im confusing you 
But the code i have written so far, does it look ok? Or do you guys, with a little more experience any other suggestions of what i should do?
Only criteria is that it has to be a VB script (or possible 2 or more) to do all this.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|