Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mapping drives for multiple groups

Status
Not open for further replies.

acl03

MIS
Jun 13, 2005
1,077
US
Hello,

I've been using a modified version of Mark's logon script for some time.

I realized though, what if a user is in multiple groups, each getting drivemappings specific to that group? Using a CASE statement isn't the best way to go, is it? Am I right in thinking that a case will exit once one returns true?

Should I use separate If statements for each group instead, or does anyone have another recommendation?



Thanks,
Andrew
 
A case statement will not accomodate multiple group memberships. In that case (pardon the pun) I would suggest storing the drive mapping information as a dictionary with the group name as the key and the mapping info as the value. THen you could pull the mapping info for any group that the user is a member of.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
i build a dictionary object of a users intended drive mappings based on location\group membership and username, all coming from nth number of config files.
gets tricky cause you might have 2 groups wanting H drive mapped to different areas, to highlight this i use the dictionary object and log it
 
Pardon my lack of VBS knowledge. Is a dictionary object like a hash in perl?



Thanks,
Andrew
 
Think one of you guys could write up a quick example if you get a chance?

Say i have:

GroupA:
p: \\server1\share
q: \\server2\share

GroupB:
p: \\server1\share
s: \\server3\share


User is a member of both groups, so would get 3 mappings in total (as p: is the same for both groups).



Thanks,
Andrew
 
Guys you are really working this in totally the wrong way here. You need to review the code.

Andrew, my script is designed to work if the user is a member of multiple groups. The important factor is that within each group you are not duplicating drive letters, otherwise the last group processed will win the drive letter.

If you study the code, you will see that the Select Case statement is included within a For Each Next statement.

It is true that a Select Case will exit, that is what it is supposed to do. The For Each Next passes a group name to the Select case for evaluation and processing. Then it passes the NEXT GROUP and so on until each group membership is processed. Assign different drive letters to each groups mappings and the user can be a member of as many groups as you want and get all of the applicable drive mappings you need.


I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Duh, i forgot that it's within the For loop. So i think the issue here is that I'm using the same letter.

I'll look into it a bit more. Thanks for the help guys.



Thanks,
Andrew
 
i would still opt for dictionary object otherwise you end up with multiple pointless drive mappings which just get overwritten,,,and in some respects it allows for better error checking logging before entering into a drive mapping sub
 
I also think a .Exists would be faster than going through however many cases you need to go through to find the right one.

"Guys you are really working this in totally the wrong way here. You need to review the code."

The code was not posted.


"Is a dictionary object like a hash in perl?"

Yes they are very similar.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
The code was not posted.
Exactly my point EBGreen.

I think making the above suggestions without seeing how the Select Case was implemented in the code was not the right support path.

I must confess however that at this point I thought just about everyone on this forum has reviewed that code.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
I've been using a modified version of Mark's logon script for some time."

Tells me that I cannot assume that the code you have posted in the past and that I have reviewed is representative.

"I realized though, what if a user is in multiple groups, each getting drivemappings specific to that group? Using a CASE statement isn't the best way to go, is it? Am I right in thinking that a case will exit once one returns true?"

This tells me that the person who does know the code the most imtimately has decided that there is a problem with using Select-Case [bold]as he has implemented it[/bold]. In this particular instance it is entirely possible that he made a wrong conclusion. Until proven otherwise or I have reason to suspect otherwise, I generally assume the person writing the code more or less understands what it does. Otherwise I would need to ask that the code be posted for [bold]every question ever posed on the forum[/bold]. I do often request that code be posted when it becomes apparent that the poster either does not understand what is going on or has a problem accurately conveying what is going on. Do you immediately ask posters to post their code for every question that you respond to? Or do you work off of the information provided until it turns out that information is not adequate.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Ehh...sorry for the faulty formatting tags...too much BBC and not enough TGML lately. :)

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Whoah guys, sorry didn't mean to create all the drama. :)

I hadn't looked at the code in a while, and when i looked at it again I had a stupid moment I guess.







Thanks,
Andrew
 
I don't consider it drama. Just a difference of opinion. My apologies if anyone does perceive it as drama however.


[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Well, one more question for you guys.

If a group A is nested inside group B, and I do a mapping based on group B, is there any way to make VBScript actually see the members of group A and map the drive?

It seems that only users explicitly members of the group that VBScript is looking for will get the mapping. Is this correct?



Thanks,
Andrew
 
I do believe you are correct. Without some kind of recusion built into the script it would see the group as just another object in the list. I have seen many auditing scripts that address this. I would look for one and try to make use of the group membership recursion protion of their scripts.

Hope this helps.

Thanks

John Fuhrman
Titan Global Services
 
I'd like to add this to my comments.

Have a look here.

Code:
On Error Resume Next

SetobjUser=GetObject("LDAP://CN=Ken Myer," & _
    "OU=Finance,DC=fabrikam,DC=com") 
Set colGroups = objUser.Groups
For Each objGroup in colGroups
    Wscript.Echo objGroup.CN
    GetNested(objGroup)
Next
Function GetNested(objGroup)
    On Error Resume Next
    colMembers = objGroup.GetEx("memberOf")
    For Each strMember in colMembers
        strPath = "LDAP://" & strMember
        Set objNestedGroup = _
        GetObject(strPath)
        WScript.Echo objNestedGroup.CN
        GetNested(objNestedGroup)
    Next
End Function

Thanks

John Fuhrman
Titan Global Services
 
EBGreen, you make a logical argument and I see the logic in it. No drama inferred. :)

Andrew & SparkByte you are correct, my script does not account for nested groups. You could overcome this using the code provided by SparkByte to determine the nested groups. You might want to move the select case into a function and call it that way.

Please note that the exclusion of the subs in my sample script was by design. It is my assertion that when designing the section of code for a particular group you should already be aware of the subs it entails and design the actions to be taken such as multiple drive mappings or printer setup based on that knowledge. Enumerating through nested groups would in my personal opinion be inefficient and degrade login performance. That is just my opinion and others are welcome to disagree. Test in your own environment and do what works best for you.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
i agree with Markdmac on the recursion, you could be there forever. i just informed the admins that for drive mappings explicit membership was required...job done.

one thing i didnt implement which might be of interest is whilst checking for duplicate letter assignment if there are some then keep this available until you are finished and then map alternative 'free' letters.?? this might throw up more issues than it solves but it is one more 'option' which can be turned off or on in your config files that you can offer users
 
I was giving this some additional thought as well and have another solution to offer too.

Consider creating a new folder and share it. Within that folder create Virtual Folders that point to the content of the other shares. In doing this, you could have one drive letter that provides the shared information of several groups, all under one location. So any applications that use that drive letter will remain working, you will just have one extra folder level in the path.

Just an idea to kick around.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top