Results 1 to 4 of 4

Thread: networkdrives

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    2

    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.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: networkdrives

    Welcome to the forums.

    When you say it doesn't work, what do you mean? Are you getting errors?

  3. #3
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    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"

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    2

    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
  •  



Click Here to Expand Forum to Full Width