Page 1 of 1 1
Topic Options
#111440 - 2004-01-07 11:25 PM Determining if a Global group is in a Local Group
Wayne Miller Offline
Fresh Scripter

Registered: 2002-05-14
Posts: 30
Loc: Dallas, TX
I am using the function group member to determine if domain admins is in the local administrator group. It seems to work well except on some NT4 boxes. About 1/4 of NT 4 boxes are reporting that it does not have domain admins in the local group even though it does. Windows 2000 is working properly

Code:
  
Function Groupmembers($target, $group, optional $flag)
;NAME GroupMembers
;
;ACTION Returns an array of all group members of the specified group
;
;SYNTAX GroupMembers(Target, Group, [FLAG])
;
;PARAMETERS Target
; The Domain name or Workstation to work with. For faster workstation
; execution, include the Domain Name that the workstation is a meber of.
;
; "Kixtart/beanbag" would be working with the workstation Beanbag in the
; Kixtart domain
;
; Group
; The Group you want to query
;
; [FLAGS]
; To use the flags options add the numbers of the desired flags toghthers and
; Use that number in the flag field.
;
; Filter :(only one filter flag at a time please)
; 1 = all
; 2 = Users only
; 4 = Groups only
;
; ADSI Information(return ADSI information "pick only one")
; 8 = ADSPath field
; 16 = ADSI Object Handle
;
;RETURNS an array containing , if the ADSPath option is used the ADSPath
; will also be returned |.
;
;REMARKS ADSI com object must be installed.
;
;EXAMPLES
;this return all members of the Domain Admins group in the kixtart domain.
; $members = groupmembers("kixtart","Domain admins")
;
;
;this will will return all groups in the local administrators group on
;
;the Workstation beanbad in the kixtart domain. Also the
; $groups = groupmembers("kixtart/beanbag","Administratoos","group")
DIM $temparray[8], $member, $i, $chunk, $flag, $ADSIFlag, $filterFlag
$chunk = ubound($temparray)
$flag = val($flag)
$i = 0
$group = getobject("WinNT://$target/$group")
if vartype($group) <> 9 exit(@error) endif
select
case $flag & 1
$filterflag = 1
case $flag & 2
$filterflag = 2
case $flag & 4
$filterflag = 4
case 1
$filterflag = 1 endselect

select

case $flag & 8
$ADSIFlag = 8
case $flag & 16
$ADSIFlag = 16
endselect

for each $member in $group.members
select
case $filterflag = 2 AND $member.class = "user"
if substr($member.name,len($member.name),1) <> "$"
$temparray[$i] = $member.name
select
case $adsiflag = 8
$temparray[$i] = $member.adspath
case $adsiflag = 16
$temparray[$i] = $member
endselect
$i = $i + 1
endif

case $filterflag = 4 AND $member.class = "Group"
if substr($member.name,len($member.name),1) <> "$"
$temparray[$i] = $member.name
select
case $adsiflag = 8
$temparray[$i] = $member.adspath
case $adsiflag = 16
$temparray[$i] = $member
endselect
$i = $i + 1
endif
case $filterflag = 1
if substr($member.name,len($member.name),1) <> "$"
$temparray[$i] = $member.name
select
case $adsiflag = 8
$temparray[$i] = $member.adspath
case $adsiflag = 16
$temparray[$i] = $member
endselect
$i = $i + 1
endif
case $filterflag

;bit bucket
endselect

if $i = ubound($temparray)
redim preserve $temparray[Ubound($temparray)+$chunk]
endif
next
if $i <> 0
redim preserve $temparray[$i-1]
$groupmembers=$temparray
endif
endfunction
Return



Code:
 
; Used to determine if the local adminstrator group contains all the groups necessary
Call "@SCRIPTDIR\groupmember.udf"

$domainadmin="no domainadmin present"


$Administratorsgroup = GroupMembers("@wksta","Administrators",16)

; Users the function groupmembers to read members of Administrators Group

For Each $Administrators In $Administratorsgroup
$Var = $Administrators.Name ; This was needed. The GroupAdd function would not work with $Administrators.name

If $var="Domain Admins"
$domainadmin="Domain Admins Present"
EndIf

Next
$logpath="c:\"
WriteProfileString ("$logpath\smsinventory.log", "Inventory", "@WKSTA", ",@time,@date,@userid, $domainadmin")



Top
#111441 - 2004-01-08 12:13 AM Re: Determining if a Global group is in a Local Group
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
;REMARKS ADSI com object must be installed.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#111442 - 2004-01-08 04:24 AM Re: Determining if a Global group is in a Local Group
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Which means it has to be installed on the target server as well as the computer form which the script is being run.
_________________________
There are two types of vessels, submarines and targets.

Top
#111443 - 2004-01-08 05:56 AM Re: Determining if a Global group is in a Local Group
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You can use my Win32Admin.DLL ( http://home.comcast.net/~habullock/Win32Admin.htm#Group ) without installing ADSI on all those NT4 clients. Using a centrally executed Admin script, you can use:

GrpEnumMembers($Server, 'local', LocalAdminGrp($Server))

then loop through the result. Sample code is on the web site.


Program:Win32Admin3.zip (835K) Ver: 2.0.2.0 handles the results more gracefully. See the example code. Let me know if you have any questions.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#111444 - 2004-01-08 06:40 AM Re: Determining if a Global group is in a Local Group
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
I thought you updated this DLL towards the end of 2003 Howard but the web page says 2002

Am I thinking of another Admin DLL you have?

Top
#111445 - 2004-01-08 02:54 PM Re: Determining if a Global group is in a Local Group
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Program:Win32Admin3.zip (835K) Ver: 2.0.2.0 is what contains the updated code. I have not had much feedback on this new version of the DLL and as a result have lost some interest in project.

My page: Last Updated: 2003-11-30 14:07:30 -0500

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#111446 - 2004-01-08 07:47 PM Re: Determining if a Global group is in a Local Group
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Would this work for you?

Code:
$domainAdmins = "WinNT://domain/domain admins"	
$localAdmins = getobject("WinNT://" + @wksta + "/Administrators")
if $localAdmins.IsMember($domainAdmins)
? "Domain Admins in local admin group"
else
? "Domain Admins is NOT in local admin group"
endif

_________________________
Eric

Top
#111447 - 2004-01-08 08:07 PM Re: Determining if a Global group is in a Local Group
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
...back to my original remark.

ADSI com object must be installed.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 811 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.061 seconds in which 0.026 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