Page 1 of 1 1
Topic Options
#204493 - 2012-03-16 05:01 PM GetInfoEx and tokengroups attribute
tmunro55 Offline
Just in Town

Registered: 2012-03-16
Posts: 3
Loc: Canada
Hi all,

I'm trying to use the "tokengroups" attribute of the user's security token to enumerate all group SIDs (which includes nested groups). I've referenced this forum article http://www.kixtart.org/forums/ubbthreads...true#Post130488 for syntax and this Microsoft support artice http://support.microsoft.com/kb/301916 for logic flow. The data is coming up blank.

If you are testing this $CurrentUser must be a valid user in your domain.
Any ideas or help would be greatly appreciated.

 Code:
$ADS_NAME_TYPE_NT4 = 3
$ADS_NAME_TYPE_1779 = 1

$CurrentUser = "AnyUserHere"
$NameTrans = CreateObject("nametranslate")
$NameTrans.set($ADS_NAME_TYPE_NT4, "YourDomain\" + $CurrentUser)
$DN = $NameTrans.get($ADS_NAME_TYPE_1779)
$oUser = GetObject("LDAP://" + $DN)
$arrTG = "tokengroups",""
$oUser.GetInfoEx($arrTG, 0)
$GroupList = $oUser.GetEx("tokengroups")
$oCvrt = CreateObject("ADs.ArrayConvert")

? "" + (ubound($GroupList)+1) + " entries returned"
?"Listing groups"?
For $i = 0 to ubound($GroupList)
	$hexSID = $oCvrt.CvOctetStr2vHexStr($Grouplist[$i])
	$oGroup = getObject("LDAP://<SID=" + $hexSID + ">")
	? $oGroup.Get("cn")
Next
?


Edited by Mart (2012-03-17 12:39 PM)
Edit Reason: Please use code tags when posting code.
_________________________
-- Tim

Lack of planning on your part,
does not make an emergency on my part.

Top
#204494 - 2012-03-16 05:21 PM Re: GetInfoEx and tokengroups attribute [Re: tmunro55]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
$NameTrans = CreateObject("nametranslate")

does that actually work?
_________________________
!

download KiXnet

Top
#204495 - 2012-03-16 05:24 PM Re: GetInfoEx and tokengroups attribute [Re: Lonkero]
tmunro55 Offline
Just in Town

Registered: 2012-03-16
Posts: 3
Loc: Canada
Quite nicely.
_________________________
-- Tim

Lack of planning on your part,
does not make an emergency on my part.

Top
#204496 - 2012-03-16 05:39 PM Re: GetInfoEx and tokengroups attribute [Re: tmunro55]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
This link is to a vbscript... but it may provide you with a hint somewhere...
http://www.rlmueller.net/Programs/IsMember8.txt

Top
#204499 - 2012-03-16 06:34 PM Re: GetInfoEx and tokengroups attribute [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
and this might help too...

ListNestedGroups() -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=159690#Post159690

Top
#204504 - 2012-03-16 07:45 PM Re: GetInfoEx and tokengroups attribute [Re: Allen]
tmunro55 Offline
Just in Town

Registered: 2012-03-16
Posts: 3
Loc: Canada
Well, well. It turns out the solution is right here in this forum:

http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=128970

Thanks to Richard H. Excellent bit of code, and works perfectly.
_________________________
-- Tim

Lack of planning on your part,
does not make an emergency on my part.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 739 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.096 seconds in which 0.066 seconds were spent on a total of 13 queries. Zlib compression enabled.

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