Page 1 of 1 1
Topic Options
#150408 - 2005-10-22 12:00 AM Doing an InGroup() on a different user?
sixdoubleo Offline
Starting to like KiXtart

Registered: 2004-02-06
Posts: 118
Loc: California, US
What is the best way to perform an InGroup on a different user (not the one running the script)???

Something like...

If UserInGroup($UserID, $Group)
Do Something
EndIf

Currently I enumerate the groups from the user's object, but that only gives me groups that the user is immediately a member of...not groups that the user is a member of via nesting (the way InGroup() does.)


Edited by sixdoubleo (2005-10-22 12:09 AM)

Top
#150409 - 2005-10-22 12:47 AM Re: Doing an InGroup() on a different user?
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
You may want to query AD with one of the LDAP UDFs.
_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5

Top
#150410 - 2005-10-22 01:05 AM Re: Doing an InGroup() on a different user?
sixdoubleo Offline
Starting to like KiXtart

Registered: 2004-02-06
Posts: 118
Loc: California, US
Quote:

You may want to query AD with one of the LDAP UDFs.




But what would I query? At best couldn't I just return a list of groups the user is a member of? Or is there a way to do that with an AD query? I think that's pretty much what I am doing now but like I said, I only get a list of groups that the user is immediately a member of.

Top
#150411 - 2005-10-22 01:21 AM Re: Doing an InGroup() on a different user?
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
If the INGROUP function only queries the groups the script initiator is a member of, then another method like querying AD for user membership, then using the results in an array may be a work around for your situation.

I'm not intimately familiar with the LDAP querying UDFs, so my recommendation was more of an impression of what may be a good direction for you to go, rather than an authoritative suggestion.
_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5

Top
#150412 - 2005-10-22 02:22 AM Re: Doing an InGroup() on a different user?
sixdoubleo Offline
Starting to like KiXtart

Registered: 2004-02-06
Posts: 118
Loc: California, US
Quote:

If the INGROUP function only queries the groups the script initiator is a member of, then another method like querying AD for user membership, then using the results in an array may be a work around for your situation.

I'm not intimately familiar with the LDAP querying UDFs, so my recommendation was more of an impression of what may be a good direction for you to go, rather than an authoritative suggestion.




Right. Well, the nice thing about InGroup() is that it checks nested membership. So if I'm a member of "Division Admins" which is a member of "Department Admins", then If InGroup("Department Admins") would be true.

Dumping group names from AD would only give me the immediate groups that the user is a member of...I would then need to recursively check membership on those groups. If that's the way I need to go about this, then that's what I'll do...but I just wanted to see if somebody had already written something.

Top
#150413 - 2005-10-22 02:32 AM Re: Doing an InGroup() on a different user?
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
Don't stop waiting for other Korg'ers to chime in. Again, I might just be speaking out my ars' so, hopefully, someone else has a silver bullet answer for your question that is more direct than query, query, query, GOOSE.

_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5

Top
#150414 - 2005-10-26 05:34 PM Re: Doing an InGroup() on a different user?
sixdoubleo Offline
Starting to like KiXtart

Registered: 2004-02-06
Posts: 118
Loc: California, US
So any ideas guys??? Is my only option to dump the groups the user is a member and then recursively keep dumping membership?
Top
#150415 - 2005-10-26 06:04 PM Re: Doing an InGroup() on a different user?
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
I'm pretty sure the 'group' object in AD has something like an IsMember function that takes an adsPath. Do some research, i know i've seen it before (and probably wrote a few times too).
Top
#150416 - 2005-10-26 06:09 PM Re: Doing an InGroup() on a different user?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Yes, you can use ADSI to list the groups a particular user is a member of. Did you check the UDF library?
_________________________
There are two types of vessels, submarines and targets.

Top
#150417 - 2005-10-26 06:14 PM Re: Doing an InGroup() on a different user?
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Vica Versa is what i was actually getting at. Using ADSI to check group membership - not listing anything.
Top
#150418 - 2005-10-26 09:32 PM Re: Doing an InGroup() on a different user?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/iadsgroup.asp for a method to return the group memberships of an arbitrary user.
_________________________
There are two types of vessels, submarines and targets.

Top
#150419 - 2005-10-26 11:34 PM Re: Doing an InGroup() on a different user?
sixdoubleo Offline
Starting to like KiXtart

Registered: 2004-02-06
Posts: 118
Loc: California, US
Quote:

See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/iadsgroup.asp for a method to return the group memberships of an arbitrary user.




Thanks. But in looking at the documentation for "IsMember" it says:

bMember
[out] Pointer to a VARIANT_BOOL value that receives VARIANT_TRUE if the object is an immediate member of the group or VARIANT_FALSE otherwise.

My testing confirms this. It reports a true when the user is an immediate member. It reports a false when the user is a member via nesting.

Code:

$User = "jsmith"
$Group = "Support Staff"

$grp = GetObject("WinNT://SCONET/" + $Group)
? $User + " ---> " + $Group + " = " + $grp.IsMember("WinNT://SCONET/"+$User)


Top
#150420 - 2005-10-26 11:50 PM Re: Doing an InGroup() on a different user?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You will have to loop to get nested memberships, there's no other way.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1047 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.075 seconds in which 0.037 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org