Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - IsMember query

Reply
 
Old 02-03-2009   #1 (permalink)
CALLUM Mac


 
 

IsMember query


Hi

I want to deploy a shortcut using the IsMember to 6 different security groups

I've used the following to deploy to a single group, how can I include 6
different groups?

If IsMember(strUserName, "Group1") = 1 Then
StrShortCutName = "Group1)
FSO.copyFile strStartMenuShortcutsFolder & strShortCutName & ".lnk"
FlogFile.WriteLine(StrShortCutName & " Shortcut Created,")

My System SpecsSystem Spec
Old 02-03-2009   #2 (permalink)
CALLUM Mac


 
 

Re: IsMember query

Hello

Thanks for responding.

I have 6 security groups based on their respective department. I want to
deploy a shortcut to each department based on their group membership

I've since found that these 6 groups contain nested groups and that the
IsMember function does not support nested groups.

What is the best way to deploy the shortcut to security groups which contain
nested groups?



"Matthias Tacke" wrote:
Quote:

> CALLUM Mac wrote:
Quote:

> > Hi
> >
> > I want to deploy a shortcut using the IsMember to 6 different security groups
> >
> > I've used the following to deploy to a single group, how can I include 6
> > different groups?
> >
> > If IsMember(strUserName, "Group1") = 1 Then
> > StrShortCutName = "Group1)
> > FSO.copyFile strStartMenuShortcutsFolder & strShortCutName & ".lnk"
> > FlogFile.WriteLine(StrShortCutName & " Shortcut Created,")
>
> It's unclear to me if you want to create one shortcut or one for every
> group the user is member of?
>
> In general
>
> arrGroups = Array("Group1","Group2")
> For Each strGroup In arrGroups
> If (IsMember(strUserName, strGroup) = True) Then ...
> Next
>
>
> --
> HTH
> Matthias
>
My System SpecsSystem Spec
Old 02-03-2009   #3 (permalink)
Matthias Tacke


 
 

Re: IsMember query

CALLUM Mac wrote:
Quote:

> Hello
>
> Thanks for responding.
>
> I have 6 security groups based on their respective department. I want to
> deploy a shortcut to each department based on their group membership
>
> I've since found that these 6 groups contain nested groups and that the
> IsMember function does not support nested groups.
>
> What is the best way to deploy the shortcut to security groups which contain
> nested groups?
>
There are variants of the IsMember Function available.

Search Google with the keywords: vbscript IsMember nested groups
<http://www.google.com/search?q=vbscript+ismember+nested+groups>

The first very informative entry is:
<http://www.rlmueller.net/freecode2.htm>

--
HTH
Matthias
My System SpecsSystem Spec
Old 02-04-2009   #4 (permalink)
Al Dunbar


 
 

Re: IsMember query


"Matthias Tacke" <Matthias@xxxxxx> wrote in message
news:gma210$q5o$1@xxxxxx
Quote:

> CALLUM Mac wrote:
Quote:

>> Hello
>>
>> Thanks for responding. I have 6 security groups based on their respective
>> department. I want to deploy a shortcut to each department based on their
>> group membership
>>
>> I've since found that these 6 groups contain nested groups and that the
>> IsMember function does not support nested groups.
>>
>> What is the best way to deploy the shortcut to security groups which
>> contain nested groups?
>>
>
> There are variants of the IsMember Function available.
>
> Search Google with the keywords: vbscript IsMember nested groups
> <http://www.google.com/search?q=vbscript+ismember+nested+groups>
>
> The first very informative entry is:
> <http://www.rlmueller.net/freecode2.htm>
but perhaps a better resource is:

http://www.rlmueller.net/freecode1.htm

/Al


My System SpecsSystem Spec
Old 03-25-2009   #5 (permalink)
jon.canning


 
 

Re: IsMember query

Just written this, not tested it thoroughly but it looks OK in
principle and is much quicker than stepping through object properties.
Let me know how you get on.

Function IsMember(sGroup)

Set oADSystemInfo = CreateObject("ADSystemInfo")
Set oDic = CreateObject("Scripting.Dictionary")
Call GetMemberOf(oADSystemInfo.UserName, oDic)
IsMember = oDic.Exists(sGroup)

End Function

Sub GetMemberOf(sDN, oDic)

Set oConnection = CreateObject("ADODB.Connection")
oConnection.Open "Provider=AdsDSOObject"
Set oRootDSE = GetObject("LDAP://RootDSE")
sLDAP = "<LDAP://" & oRootDSE.Get("defaultNamingContext") &
">;"
Set oResults = oConnection.Execute(sLDAP & "(distinguishedName=" &
sDN & ");memberof;subtree")
If Not oResults.EOF Then
aMemberOf = oResults("memberof")
If IsArray(aMemberOf) Then
For Each sMemberOf in aMemberOf
sCN = Replace(Left(sMemberOf, InStr(sMemberOf, ",") -
1), "CN=", "")
If Not oDic.Exists(sCN) Then oDic.Add sCN,
""
Call GetMemberOf(sMemberOf, oDic)
Next
End If
End If

End Sub
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Tab key query Vista General
RAM query General Discussion


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46