Multiple groups drive letter mapping? (newbie question) 
Author Message
 Multiple groups drive letter mapping? (newbie question)

Let me see if I can explain this correctly. I have two global groups, each
of which needs to map drives for certain apps. The current drive latters are
the same and the problem is when a user belongs to both groups, it will only
map one drive (obviously). Something like this:

Group 1 needs to map to Drive P \\server1\share
Group 2 needs to map to Drive P \\server2\share

If a user is a member of both groups map:

Drive X \\server1\share AND Y \\server2\share

How can I accomplish this via vbs? My current script looks like this:

IF grp.Name ="app1" then
  IF checkNetworkMapping("P:", "\\server\share") = false then
   WshNetwork.MapNetworkDrive "P:", "\\server\share"
  END IF
    End If

IF grp.Name ="app2" then
  IF checkNetworkMapping("P:", "\\server\share") = false then
   WshNetwork.MapNetworkDrive "P:", "\\server\share"
  END IF
    End If

Could I simply do this:

IF grp.Name ="app1" & "app2" then
  IF checkNetworkMapping("P:", "\\server\share") = false then
   WshNetwork.MapNetworkDrive "P:", "\\server\share"
  IF checkNetworkMapping("T:", "\\server\share") = false then
   WshNetwork.MapNetworkDrive "T:", "\\server\share"
 END IF
    End If

Thanks for any help.
jaco

ps - I am totally new to scripting.



Mon, 25 Jul 2005 11:02:58 GMT  
 Multiple groups drive letter mapping? (newbie question)


Quote:
> Let me see if I can explain this correctly. I have two global groups, each
> of which needs to map drives for certain apps. The current drive latters
are
> the same and the problem is when a user belongs to both groups, it will
only
> map one drive (obviously). Something like this:

> Group 1 needs to map to Drive P \\server1\share
> Group 2 needs to map to Drive P \\server2\share

> If a user is a member of both groups map:

> Drive X \\server1\share AND Y \\server2\share

> How can I accomplish this via vbs?

Simplest solution: if the apps can function when mapped as X and Y, why not
ALWAYS use X: for server1 and Y: for server 2?

Quote:
>    My current script looks like this:

> IF grp.Name ="app1" then
>   IF checkNetworkMapping("P:", "\\server\share") = false then
>    WshNetwork.MapNetworkDrive "P:", "\\server\share"
>   END IF
>     End If

> IF grp.Name ="app2" then
>   IF checkNetworkMapping("P:", "\\server\share") = false then
>    WshNetwork.MapNetworkDrive "P:", "\\server\share"
>   END IF
>     End If

> Could I simply do this:

> IF grp.Name ="app1" & "app2" then

This is equivalent to:

    IF grp.Name = "app1app2"

If you don't have a group with such a name, why test for it?

Quote:
>   IF checkNetworkMapping("P:", "\\server\share") = false then
>    WshNetwork.MapNetworkDrive "P:", "\\server\share"
>   IF checkNetworkMapping("T:", "\\server\share") = false then
>    WshNetwork.MapNetworkDrive "T:", "\\server\share"
>  END IF
>     End If

Is this your /entire/ script? where does object grp get defined, and what is
it defined as?

Forget VBScript for a moment, and consider the logic you want to implement.
Is it something like this:

    if user is in both groups 1 and 2 then
        map x to server1
        map y to server2
    elseif user is in group 1 then
        map p to server1
    elseif user is in group 2 then
        map p to server2
    end if

What you really need is a way to find out the membership of the current user
in the two groups. Where does grp.name come in to this?

You need an "IsInGroup" function. This could be done via ADSI, just
enumerate all the groups the user belongs to and check each one to see if it
is one of these. Or you could enumerate all members of the two groups to see
if any of the members is the current user. Trouble with this is if you are
using active directory, he could be a member indirectly by being a member of
some third group that is itself a member of one of these two.

Another way is to set the permission on the share or underlying folder (or a
flag file) such that a non-member of the group cannot see it. IsInGroup
become CanSeeShare:

    sub CanSeeShare( uncpath )
        set fso = createobject("scripting.filesystemobject")
        CanSeeShare = fso.folderexists(uncpath)
        set fso = nothing
    end sub

Your script then becomes:

isingroup1 = canseeshare( \\server1\share )
isingroup2 = canseeshare( \\server2\share )

if isingroup1 and isingroup2 then
    ' see above
elseif isingroup1
    ' see above
elseif isingroup2
    ' see above
end if

/Al



Mon, 25 Jul 2005 13:28:06 GMT  
 Multiple groups drive letter mapping? (newbie question)


Quote:
>Let me see if I can explain this correctly. I have two global groups, each
>of which needs to map drives for certain apps. The current drive latters are
>the same and the problem is when a user belongs to both groups, it will only
>map one drive (obviously). Something like this:

Not that obvious, it works for many others.  :)

Quote:
>Group 1 needs to map to Drive P \\server1\share
>Group 2 needs to map to Drive P \\server2\share

>If a user is a member of both groups map:

>Drive X \\server1\share AND Y \\server2\share

>How can I accomplish this via vbs? My current script looks like this:

I have to ask, if X and Y work when a user is a member of both
groupos, why wouldn't X work if they were a member of one and Y for
the other?  In other words, skip the P: drive.

Quote:
>Could I simply do this:

>IF grp.Name ="app1" & "app2" then

Except your syntax is wrong, since this actually checks for group
membership in the "app1app2" group.  You'd need:

IF grp.Name ="app1" And grp.Name = "app2" Then

Quote:
>  IF checkNetworkMapping("P:", "\\server\share") = false then
>   WshNetwork.MapNetworkDrive "P:", "\\server\share"
>  IF checkNetworkMapping("T:", "\\server\share") = false then
>   WshNetwork.MapNetworkDrive "T:", "\\server\share"
> END IF
>    End If

Now you add drive T: into the mix. !

I think your first error is not thinking out your drive mapping
structure well enough.  Start looking at:

If member of group 1 then X: = \\server1\share
If member of group 2 then Y: = \\server2\share

That way if a member of both, they get both drives.  Only use the same
drive letter if the mappings are mutually exclusive.

Jeff



Mon, 25 Jul 2005 23:10:10 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. newbie question-Map network drive vb.net

2. get mapped drive letter from UNC path

3. Specifying server directory without mapped drive letter

4. Getting mapped path from drive letter

5. Mapping a drive letter to a memory location?

6. Mapping a Server to a Drive Letter

7. VBScript for mapping drive letters

8. Network Shortcuts Cause New Drive Letter Mappings

9. Group Drive Mappings

10. map drive per global group

11. Mapping Drives based on NT global groups

12. If member of a group then map network drive

 

 
Powered by phpBB® Forum Software