Page 1 of 1 1
Topic Options
#18945 - 2002-03-21 11:12 PM Is user part of admnistrators group
dbortunk Offline
Fresh Scripter

Registered: 2001-05-18
Posts: 36
Loc: USA
I need kix to see if a certian domain user is part of every machine local administrator group. I t should not check if the current user is part of the local admin group but if a specific user is. If the users is not part of the local admin group then kix will run a script (I already have this) that will addd the user to the group? Anyone can help?
Top
#18946 - 2002-03-22 12:51 AM Re: Is user part of admnistrators group
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
is this a local or admin script?

what OS NT or w2k/xp

you can do this using ADSI.

to run ADSI on a local NT box you will need to install it. but you do not need to install ADSI on a NT box if you do these changes from a remote computer that already has ADSI installed.

w2k/xp come shipped with ADSI installed.

you can use this UDF to pull the members of a group.

GroupMembers()

here is a bit of code.

code:
$searchuser = "brycel"
$users = groupmembers(@domain/@wksta,"administrators",2)

$totalusers = ubound($users)

for $i = 0 to $totalusers
if $users[$i] = $SearchUser
? "the user '$searchuser' was found the the group Administrators"
$i = $totalusers
endif
next

Bryce

Top
#18947 - 2002-03-22 12:55 AM Re: Is user part of admnistrators group
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
also....

code:
$searchuser = "brycel"
$users = groupmembers(@wksta,"administrators",2)

$totalusers = ubound($users)

for $i = 0 to $totalusers
if $users[$i] = $SearchUser
? "the user '$searchuser' was found the the group Administrators"
$i = $totalusers
else
if $i = $totalusers
? "the user '$searchuser' was not found in the group administrators"
endif
endif
next


Top
#18948 - 2002-03-22 02:32 AM Re: Is user part of admnistrators group
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Can I assume that you want to run this from a central console and check/update each computer as required?
You have to have a network account that already has Admin access to each computer.

code:
$account = "WinNT://@Ldomain/user1"
IF Open(3, "c:\Computers.txt") = 0
$Computer = ReadLine(3)
WHILE @ERROR = 0
$Group = GetObject("WinNT://$Computer/Administrators,Group")
if @error = 0
if $Group.IsMember($account)
? "$Computer: Is member"
else
? "Is NOT a Member"
$Group.Add($Account)
if @error = 0
? "$Computer: Added $account to group"
else
? "$Computer: error @error adding $account to group"
endif
endif
$Computer = ReadLine(3)
else
? "$Computer: error @error connecting to group"
endif
LOOP
ENDIF



[ 22 March 2002, 02:37: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

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 5139 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.161 seconds in which 0.117 seconds were spent on a total of 11 queries. Zlib compression enabled.

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