Page 1 of 1 1
Topic Options
#157317 - 2006-02-16 02:45 AM Problems with ComputerInGroup() and/or fnInGroupAD()
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
anyone had problems with these? I've verified that my computer IS in Domain Computers and both of these functions return false. Anyone know why?

Code:
$domain = 'microsoft.com'

If ComputerInGroup('Domain Computers') = 1
"true"
Else
? "CID false" +@ERROR +@SERROR
Endif

If fnInGroupAD('Domain Computers',1)
"true"
Else
? "FN false" +@ERROR +@SERROR
Endif

get $


Function ComputerInGroup($group,optional $Domain)
Dim $oGrp
if not $domain $domain=@domain endif
$oGrp = GetObject("WinNT://" + $domain + "/" + $group + ",group" )
if @error exit 1 endif

if $oGrp.IsMember("WinNT://" + $domain + "/" + @wksta + "$$" )
$ComputerInGroup=1
else
$ComputerInGroup=0
endif
endfunction

Function fnInGroupAD($sGroup,Optional $bComputer)
Dim $objSys,$objTarget,$aMemberOf,$sMemberOf
$objSys = CreateObject("ADSystemInfo")
$objTarget = GetObject("LDAP://"+Iif($bComputer,$objSys.ComputerName,$objSys.UserName))
$aMemberOf = $objTarget.GetEx("memberOf")
For Each $sMemberOf in $aMemberOf
If InStr($sMemberOf,"CN="+$sGroup+",")
$fnInGroupAD = Not 0
Exit
EndIf
Next
$fnInGroupAD = NOT 1
EndFunction



Edit: both return false.
Edit2: added functions so you could see the versions I'm using.


Edited by thepip3r (2006-02-16 04:08 AM)

Top
#157318 - 2006-02-16 02:52 PM Re: Problems with ComputerInGroup() and/or fnInGroupAD()
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
The Domain Computers groups, in my experience, is a special group in that it is sort of "hidden" when you enumerate groups using ADSI methods.
Top
#157319 - 2006-02-16 05:18 PM Re: Problems with ComputerInGroup() and/or fnInGroupAD()
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
If that's true, a mod may want to change the example for ComputerInGroup() then:

http://www.kixtart.org/ubbthreads/showfl...true#Post131287

thank you for the response though Chris. the fn function worked but computeringroup did not. thanx for the suggestion....

Top
Page 1 of 1 1


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

Who's Online
0 registered and 756 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.051 seconds in which 0.024 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