Mapping drives based on group membership 
Author Message
 Mapping drives based on group membership

I've posted this question before and someone was kind enough to offer
a suggestion.  Unfortunately, it did not work.

In basic terms I want the script to compare the user name against
group membership.  If the user is a member of the group, I want a
drive mapped to a share.  If the user is not a member of the group, I
want the script to continue without mapping the drive.

I'm using ADSI's runtime components to try and do this but am not
having any luck.  The drives map regardless of whether the user is in
the group.  Here's the code:

----------------
set net = wscript.CreateObject("wscript.network")
set shell = wscript.CreateObject("wscript.shell")
set environment = shell.Environment("process")

Function clear()
strGroup = Nothing
set oGroup = Nothing
End Function

strDomain = net.UserDomain
strUser = net.UserName

set oDomain = GetObject("WinNT://" & strDomain)
set oUser = GetObject("WinNT://" & strDomain & "/" strUser)

strGroup = "Administrators"
set oGroup = GetObject("WinNT://" & strDomain & "/" strGroup)

For Every oUser In oGroup.Members
        net.MapNetworkDrive "R:", "\\cvs\archives"
        net.MapNetworkDrive "L:", "\\cvs\log$"
Next

clear

----------------------------------

That's what I have.  It's pieced together by examples I've seen.  I
have no clue if the For Every...In is the correct argument to use.  It
seems to me that it should be an If...Then...Else, but I can't find
any examples based on that.

I've also tried:

-------------------------------------
For Every Member in oGroup.Members
        net.MapNetworkDrive (local, share)
Next
------------------------------------

That hasn't worked.

I can write scripts that enumerate the users of a group, or the groups
a user belongs to.  But I can't seem to get to get it to check group
membership and act accordingly.

Any help is greatly appreciated.

-----------
"I heard we're going to Ape Island."
"Yeah, to capture a giant ape."
"I wish we were going to Candy Apple Island."
"Candy Apple Island?  What do they got there?"
"Apes.  But they're not so big."



Mon, 09 Dec 2002 03:00:00 GMT  
 Mapping drives based on group membership
Try this:

For Each UserGroup In oUser.Groups
  UserGroupName = UserGroup.Name
         If LCase(UserGroupName) = "Group name goes here" Then
net.MapNetworkDrive "R:", "\\cvs\archives": net.MapNetworkDrive "L:",
"\\cvs\log$"
        Next
If the user is a member of the group "Group name goes here" then it will do
what comes after the 'then' command.
Let me know if I can help you further


Quote:
> I've posted this question before and someone was kind enough to offer
> a suggestion.  Unfortunately, it did not work.

> In basic terms I want the script to compare the user name against
> group membership.  If the user is a member of the group, I want a
> drive mapped to a share.  If the user is not a member of the group, I
> want the script to continue without mapping the drive.

> I'm using ADSI's runtime components to try and do this but am not
> having any luck.  The drives map regardless of whether the user is in
> the group.  Here's the code:

> ----------------
> set net = wscript.CreateObject("wscript.network")
> set shell = wscript.CreateObject("wscript.shell")
> set environment = shell.Environment("process")

> Function clear()
> strGroup = Nothing
> set oGroup = Nothing
> End Function

> strDomain = net.UserDomain
> strUser = net.UserName

> set oDomain = GetObject("WinNT://" & strDomain)
> set oUser = GetObject("WinNT://" & strDomain & "/" strUser)

> strGroup = "Administrators"
> set oGroup = GetObject("WinNT://" & strDomain & "/" strGroup)

> For Every oUser In oGroup.Members
> net.MapNetworkDrive "R:", "\\cvs\archives"
> net.MapNetworkDrive "L:", "\\cvs\log$"
> Next

> clear

> ----------------------------------

> That's what I have.  It's pieced together by examples I've seen.  I
> have no clue if the For Every...In is the correct argument to use.  It
> seems to me that it should be an If...Then...Else, but I can't find
> any examples based on that.

> I've also tried:

> -------------------------------------
> For Every Member in oGroup.Members
> net.MapNetworkDrive (local, share)
> Next
> ------------------------------------

> That hasn't worked.

> I can write scripts that enumerate the users of a group, or the groups
> a user belongs to.  But I can't seem to get to get it to check group
> membership and act accordingly.

> Any help is greatly appreciated.

> -----------
> "I heard we're going to Ape Island."
> "Yeah, to capture a giant ape."
> "I wish we were going to Candy Apple Island."
> "Candy Apple Island?  What do they got there?"
> "Apes.  But they're not so big."



Mon, 09 Dec 2002 03:00:00 GMT  
 Mapping drives based on group membership
On Thu, 22 Jun 2000 15:38:43 +1200 in microsoft.public.scripting.wsh,

controlled substance and decided to share with us the following:

Quote:
>Try this:

>For Each UserGroup In oUser.Groups
>  UserGroupName = UserGroup.Name
>         If LCase(UserGroupName) = "Group name goes here" Then
>net.MapNetworkDrive "R:", "\\cvs\archives": net.MapNetworkDrive "L:",
>"\\cvs\log$"
>        Next
>If the user is a member of the group "Group name goes here" then it will do
>what comes after the 'then' command.
>Let me know if I can help you further


I'll give it a run.

Meanwhile, do you know where I can get a language reference for the
ADSI functions?  There is a help file I d/l'd with PrimalScript 2.0
that goes through some of the FSO functions, but I haven't found
anything similar for ADSI.

Thanks.

Quote:


>> I've posted this question before and someone was kind enough to offer
>> a suggestion.  Unfortunately, it did not work.

>> In basic terms I want the script to compare the user name against
>> group membership.  If the user is a member of the group, I want a
>> drive mapped to a share.  If the user is not a member of the group, I
>> want the script to continue without mapping the drive.

>> I'm using ADSI's runtime components to try and do this but am not
>> having any luck.  The drives map regardless of whether the user is in
>> the group.  Here's the code:

>> ----------------
>> set net = wscript.CreateObject("wscript.network")
>> set shell = wscript.CreateObject("wscript.shell")
>> set environment = shell.Environment("process")

>> Function clear()
>> strGroup = Nothing
>> set oGroup = Nothing
>> End Function

>> strDomain = net.UserDomain
>> strUser = net.UserName

>> set oDomain = GetObject("WinNT://" & strDomain)
>> set oUser = GetObject("WinNT://" & strDomain & "/" strUser)

>> strGroup = "Administrators"
>> set oGroup = GetObject("WinNT://" & strDomain & "/" strGroup)

>> For Every oUser In oGroup.Members
>> net.MapNetworkDrive "R:", "\\cvs\archives"
>> net.MapNetworkDrive "L:", "\\cvs\log$"
>> Next

>> clear

>> ----------------------------------

>> That's what I have.  It's pieced together by examples I've seen.  I
>> have no clue if the For Every...In is the correct argument to use.  It
>> seems to me that it should be an If...Then...Else, but I can't find
>> any examples based on that.

>> I've also tried:

>> -------------------------------------
>> For Every Member in oGroup.Members
>> net.MapNetworkDrive (local, share)
>> Next
>> ------------------------------------

>> That hasn't worked.

>> I can write scripts that enumerate the users of a group, or the groups
>> a user belongs to.  But I can't seem to get to get it to check group
>> membership and act accordingly.

>> Any help is greatly appreciated.

>> -----------
>> "I heard we're going to Ape Island."
>> "Yeah, to capture a giant ape."
>> "I wish we were going to Candy Apple Island."
>> "Candy Apple Island?  What do they got there?"
>> "Apes.  But they're not so big."

-----------
"I heard we're going to Ape Island."
"Yeah, to capture a giant ape."
"I wish we were going to Candy Apple Island."
"Candy Apple Island?  What do they got there?"
"Apes.  But they're not so big."


Mon, 09 Dec 2002 03:00:00 GMT  
 Mapping drives based on group membership
There are some places on the web where you can find reference material, e.g.
at

http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/iisre...
aat.htm

I haven't found a downloadable helpfile, but it is part of MSDN (the one on
CD/DVD). If you would like to use just the help file associated with ADSI,
that would be netdir.chm in your MSDN folder.

Alexander Riedel
Lead Engineer
SAPIEN Technologies, Inc.

www.primalscript.com


Quote:
> On Thu, 22 Jun 2000 15:38:43 +1200 in microsoft.public.scripting.wsh,

> controlled substance and decided to share with us the following:

> >Try this:

> >For Each UserGroup In oUser.Groups
> >  UserGroupName = UserGroup.Name
> >         If LCase(UserGroupName) = "Group name goes here" Then
> >net.MapNetworkDrive "R:", "\\cvs\archives": net.MapNetworkDrive "L:",
> >"\\cvs\log$"
> >        Next
> >If the user is a member of the group "Group name goes here" then it will
do
> >what comes after the 'then' command.
> >Let me know if I can help you further

> I'll give it a run.

> Meanwhile, do you know where I can get a language reference for the
> ADSI functions?  There is a help file I d/l'd with PrimalScript 2.0
> that goes through some of the FSO functions, but I haven't found
> anything similar for ADSI.

> Thanks.



> >> I've posted this question before and someone was kind enough to offer
> >> a suggestion.  Unfortunately, it did not work.

> >> In basic terms I want the script to compare the user name against
> >> group membership.  If the user is a member of the group, I want a
> >> drive mapped to a share.  If the user is not a member of the group, I
> >> want the script to continue without mapping the drive.

> >> I'm using ADSI's runtime components to try and do this but am not
> >> having any luck.  The drives map regardless of whether the user is in
> >> the group.  Here's the code:

> >> ----------------
> >> set net = wscript.CreateObject("wscript.network")
> >> set shell = wscript.CreateObject("wscript.shell")
> >> set environment = shell.Environment("process")

> >> Function clear()
> >> strGroup = Nothing
> >> set oGroup = Nothing
> >> End Function

> >> strDomain = net.UserDomain
> >> strUser = net.UserName

> >> set oDomain = GetObject("WinNT://" & strDomain)
> >> set oUser = GetObject("WinNT://" & strDomain & "/" strUser)

> >> strGroup = "Administrators"
> >> set oGroup = GetObject("WinNT://" & strDomain & "/" strGroup)

> >> For Every oUser In oGroup.Members
> >> net.MapNetworkDrive "R:", "\\cvs\archives"
> >> net.MapNetworkDrive "L:", "\\cvs\log$"
> >> Next

> >> clear

> >> ----------------------------------

> >> That's what I have.  It's pieced together by examples I've seen.  I
> >> have no clue if the For Every...In is the correct argument to use.  It
> >> seems to me that it should be an If...Then...Else, but I can't find
> >> any examples based on that.

> >> I've also tried:

> >> -------------------------------------
> >> For Every Member in oGroup.Members
> >> net.MapNetworkDrive (local, share)
> >> Next
> >> ------------------------------------

> >> That hasn't worked.

> >> I can write scripts that enumerate the users of a group, or the groups
> >> a user belongs to.  But I can't seem to get to get it to check group
> >> membership and act accordingly.

> >> Any help is greatly appreciated.

> >> -----------
> >> "I heard we're going to Ape Island."
> >> "Yeah, to capture a giant ape."
> >> "I wish we were going to Candy Apple Island."
> >> "Candy Apple Island?  What do they got there?"
> >> "Apes.  But they're not so big."

> -----------
> "I heard we're going to Ape Island."
> "Yeah, to capture a giant ape."
> "I wish we were going to Candy Apple Island."
> "Candy Apple Island?  What do they got there?"
> "Apes.  But they're not so big."



Mon, 09 Dec 2002 03:00:00 GMT  
 Mapping drives based on group membership
On Thu, 22 Jun 2000 10:04:48 -0700 in microsoft.public.scripting.wsh,

controlled substance and decided to share with us the following:

Quote:
>There are some places on the web where you can find reference material, e.g.
>at

>http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/iisre...
>aat.htm

>I haven't found a downloadable helpfile, but it is part of MSDN (the one on
>CD/DVD). If you would like to use just the help file associated with ADSI,
>that would be netdir.chm in your MSDN folder.

Will check.

BTW--the method Peter suggested worked great.

And thanks for PrimalScipt--great tool.

Quote:
>Alexander Riedel
>Lead Engineer
>SAPIEN Technologies, Inc.

>www.primalscript.com



>> On Thu, 22 Jun 2000 15:38:43 +1200 in microsoft.public.scripting.wsh,

>> controlled substance and decided to share with us the following:

>> >Try this:

>> >For Each UserGroup In oUser.Groups
>> >  UserGroupName = UserGroup.Name
>> >         If LCase(UserGroupName) = "Group name goes here" Then
>> >net.MapNetworkDrive "R:", "\\cvs\archives": net.MapNetworkDrive "L:",
>> >"\\cvs\log$"
>> >        Next
>> >If the user is a member of the group "Group name goes here" then it will
>do
>> >what comes after the 'then' command.
>> >Let me know if I can help you further

>> I'll give it a run.

>> Meanwhile, do you know where I can get a language reference for the
>> ADSI functions?  There is a help file I d/l'd with PrimalScript 2.0
>> that goes through some of the FSO functions, but I haven't found
>> anything similar for ADSI.

>> Thanks.



>> >> I've posted this question before and someone was kind enough to offer
>> >> a suggestion.  Unfortunately, it did not work.

>> >> In basic terms I want the script to compare the user name against
>> >> group membership.  If the user is a member of the group, I want a
>> >> drive mapped to a share.  If the user is not a member of the group, I
>> >> want the script to continue without mapping the drive.

>> >> I'm using ADSI's runtime components to try and do this but am not
>> >> having any luck.  The drives map regardless of whether the user is in
>> >> the group.  Here's the code:

>> >> ----------------
>> >> set net = wscript.CreateObject("wscript.network")
>> >> set shell = wscript.CreateObject("wscript.shell")
>> >> set environment = shell.Environment("process")

>> >> Function clear()
>> >> strGroup = Nothing
>> >> set oGroup = Nothing
>> >> End Function

>> >> strDomain = net.UserDomain
>> >> strUser = net.UserName

>> >> set oDomain = GetObject("WinNT://" & strDomain)
>> >> set oUser = GetObject("WinNT://" & strDomain & "/" strUser)

>> >> strGroup = "Administrators"
>> >> set oGroup = GetObject("WinNT://" & strDomain & "/" strGroup)

>> >> For Every oUser In oGroup.Members
>> >> net.MapNetworkDrive "R:", "\\cvs\archives"
>> >> net.MapNetworkDrive "L:", "\\cvs\log$"
>> >> Next

>> >> clear

>> >> ----------------------------------

>> >> That's what I have.  It's pieced together by examples I've seen.  I
>> >> have no clue if the For Every...In is the correct argument to use.  It
>> >> seems to me that it should be an If...Then...Else, but I can't find
>> >> any examples based on that.

>> >> I've also tried:

>> >> -------------------------------------
>> >> For Every Member in oGroup.Members
>> >> net.MapNetworkDrive (local, share)
>> >> Next
>> >> ------------------------------------

>> >> That hasn't worked.

>> >> I can write scripts that enumerate the users of a group, or the groups
>> >> a user belongs to.  But I can't seem to get to get it to check group
>> >> membership and act accordingly.

>> >> Any help is greatly appreciated.

>> >> -----------
>> >> "I heard we're going to Ape Island."
>> >> "Yeah, to capture a giant ape."
>> >> "I wish we were going to Candy Apple Island."
>> >> "Candy Apple Island?  What do they got there?"
>> >> "Apes.  But they're not so big."

>> -----------
>> "I heard we're going to Ape Island."
>> "Yeah, to capture a giant ape."
>> "I wish we were going to Candy Apple Island."
>> "Candy Apple Island?  What do they got there?"
>> "Apes.  But they're not so big."

-----------
"I heard we're going to Ape Island."
"Yeah, to capture a giant ape."
"I wish we were going to Candy Apple Island."
"Candy Apple Island?  What do they got there?"
"Apes.  But they're not so big."


Tue, 10 Dec 2002 03:00:00 GMT  
 Mapping drives based on group membership
You are very welcome. I hope we will do even better with 2.1.

Alexander Riedel
Lead Engineer
SAPIEN Technologies, Inc.

www.primalscript.com


Quote:
> On Thu, 22 Jun 2000 10:04:48 -0700 in microsoft.public.scripting.wsh,

> controlled substance and decided to share with us the following:

> >There are some places on the web where you can find reference material,
e.g.
> >at

>http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/iisre...
0
> >aat.htm

> >I haven't found a downloadable helpfile, but it is part of MSDN (the one
on
> >CD/DVD). If you would like to use just the help file associated with
ADSI,
> >that would be netdir.chm in your MSDN folder.

> Will check.

> BTW--the method Peter suggested worked great.

> And thanks for PrimalScipt--great tool.

> >Alexander Riedel
> >Lead Engineer
> >SAPIEN Technologies, Inc.

> >www.primalscript.com



> >> On Thu, 22 Jun 2000 15:38:43 +1200 in microsoft.public.scripting.wsh,

> >> controlled substance and decided to share with us the following:

> >> >Try this:

> >> >For Each UserGroup In oUser.Groups
> >> >  UserGroupName = UserGroup.Name
> >> >         If LCase(UserGroupName) = "Group name goes here" Then
> >> >net.MapNetworkDrive "R:", "\\cvs\archives": net.MapNetworkDrive "L:",
> >> >"\\cvs\log$"
> >> >        Next
> >> >If the user is a member of the group "Group name goes here" then it
will
> >do
> >> >what comes after the 'then' command.
> >> >Let me know if I can help you further

> >> I'll give it a run.

> >> Meanwhile, do you know where I can get a language reference for the
> >> ADSI functions?  There is a help file I d/l'd with PrimalScript 2.0
> >> that goes through some of the FSO functions, but I haven't found
> >> anything similar for ADSI.

> >> Thanks.


message

> >> >> I've posted this question before and someone was kind enough to
offer
> >> >> a suggestion.  Unfortunately, it did not work.

> >> >> In basic terms I want the script to compare the user name against
> >> >> group membership.  If the user is a member of the group, I want a
> >> >> drive mapped to a share.  If the user is not a member of the group,
I
> >> >> want the script to continue without mapping the drive.

> >> >> I'm using ADSI's runtime components to try and do this but am not
> >> >> having any luck.  The drives map regardless of whether the user is
in
> >> >> the group.  Here's the code:

> >> >> ----------------
> >> >> set net = wscript.CreateObject("wscript.network")
> >> >> set shell = wscript.CreateObject("wscript.shell")
> >> >> set environment = shell.Environment("process")

> >> >> Function clear()
> >> >> strGroup = Nothing
> >> >> set oGroup = Nothing
> >> >> End Function

> >> >> strDomain = net.UserDomain
> >> >> strUser = net.UserName

> >> >> set oDomain = GetObject("WinNT://" & strDomain)
> >> >> set oUser = GetObject("WinNT://" & strDomain & "/" strUser)

> >> >> strGroup = "Administrators"
> >> >> set oGroup = GetObject("WinNT://" & strDomain & "/" strGroup)

> >> >> For Every oUser In oGroup.Members
> >> >> net.MapNetworkDrive "R:", "\\cvs\archives"
> >> >> net.MapNetworkDrive "L:", "\\cvs\log$"
> >> >> Next

> >> >> clear

> >> >> ----------------------------------

> >> >> That's what I have.  It's pieced together by examples I've seen.  I
> >> >> have no clue if the For Every...In is the correct argument to use.
It
> >> >> seems to me that it should be an If...Then...Else, but I can't find
> >> >> any examples based on that.

> >> >> I've also tried:

> >> >> -------------------------------------
> >> >> For Every Member in oGroup.Members
> >> >> net.MapNetworkDrive (local, share)
> >> >> Next
> >> >> ------------------------------------

> >> >> That hasn't worked.

> >> >> I can write scripts that enumerate the users of a group, or the
groups
> >> >> a user belongs to.  But I can't seem to get to get it to check group
> >> >> membership and act accordingly.

> >> >> Any help is greatly appreciated.

> >> >> -----------
> >> >> "I heard we're going to Ape Island."
> >> >> "Yeah, to capture a giant ape."
> >> >> "I wish we were going to Candy Apple Island."
> >> >> "Candy Apple Island?  What do they got there?"
> >> >> "Apes.  But they're not so big."

> >> -----------
> >> "I heard we're going to Ape Island."
> >> "Yeah, to capture a giant ape."
> >> "I wish we were going to Candy Apple Island."
> >> "Candy Apple Island?  What do they got there?"
> >> "Apes.  But they're not so big."

> -----------
> "I heard we're going to Ape Island."
> "Yeah, to capture a giant ape."
> "I wish we were going to Candy Apple Island."
> "Candy Apple Island?  What do they got there?"
> "Apes.  But they're not so big."



Tue, 10 Dec 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Mapping drives based on group membership using ADSI with VBS

2. Mapping drives based on group membership using ADSI with VBS

3. Mapping Drives based on Group Membership for Win9x clients

4. Getting Win98 to map drives based upon Group Membership

5. Drive Mappings based on group membership again

6. Drive mappings based on group membership

7. Map Drives and Connect Printers based on OU Membership

8. Drive mapping according to group membership

9. A logon script that maps drives according to the users group memberships

10. Group Membership & Drive Mappings

11. A logon script that maps drives according to the users group memberships

12. Mapping Drives based on NT global groups

 

 
Powered by phpBB® Forum Software