Page 1 of 1 1
Topic Options
#133218 - 2005-02-01 01:28 PM Is user member of local admin group
JazzM Offline
Getting the hang of it

Registered: 2004-04-23
Posts: 91
Hi boys-n-girls :-)

Im trying remotly see if a current loged on user is member of that remote client admin group.

If $UserID InGroup("\\"+ $RemoteClient + "\" + SIDToName( "S-1-5-32-544" ) )
? "True"
Else
? "False"
Endif

Am I right?
_________________________
I will always look out from behind these eyes...

Top
#133219 - 2005-02-01 03:53 PM Re: Is user member of local admin group
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
I pretty sure your code won't work. Take a look at GroupMembers() - returns all members of a given group.
_________________________
(... better days ahead)

Top
#133220 - 2005-02-01 04:35 PM Re: Is user member of local admin group
JazzM Offline
Getting the hang of it

Registered: 2004-04-23
Posts: 91
hmmm.. mayby using WMI and do a query to remote client and get a list of local admin groups members .... then check if the current loged on user is in the list...
Should be more simple code the GroupMembers...
_________________________
I will always look out from behind these eyes...

Top
#133221 - 2005-02-01 04:39 PM Re: Is user member of local admin group
JazzM Offline
Getting the hang of it

Registered: 2004-04-23
Posts: 91
$target = "192.168.0.10"
$group = "Administrators"
$UserID = "domain\Luser"

$groups = GetObject("WinNT://$target/$group")
For Each $member in $groups
? $member

how should i proceed...
_________________________
I will always look out from behind these eyes...

Top
#133222 - 2005-02-01 04:54 PM Re: Is user member of local admin group
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
I just used the GroupMembers UDF and threw this together in a couple of secs... I tested it with an IP (like in your example) but it didn't work. However, using the actual computername did work.

Code:
 
break on

$target = "computername"
$group = "Administrators"
$UserID = "administrator"

$Members=groupmembers($target,$group)
For Each $member in $members
If $userid=$member
? "hello"
; Do something
else
; Do nothing
endif
next

_________________________
(... better days ahead)

Top
#133223 - 2005-02-01 05:27 PM Re: Is user member of local admin group
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
if you are only concerned about the currently logged on user then

Code:

if ingroup('\\' + $RemoteClient + '\Administrators')
? @userid " is an admin on " $RemoteClient
else
? @userid " is not an admin on " $RemoteClient
endif




_________________________
Eric

Top
#133224 - 2005-02-01 05:42 PM Re: Is user member of local admin group
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I think the SID to name thing is to get around localized spellings of "Administrators" as in the LocalAdmin() UDF.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#133225 - 2005-02-01 05:47 PM Re: Is user member of local admin group
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
you're right. just basically wanted to point out that it can be done with ingroup, just need the right syntax
_________________________
Eric

Top
#133226 - 2005-02-01 05:47 PM Re: Is user member of local admin group
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
I think he wants to check membership remotely, not locally. That's why I pointed him in the direction of GroupMembers.
_________________________
(... better days ahead)

Top
#133227 - 2005-02-01 05:51 PM Re: Is user member of local admin group
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
So its possible to use ingroup on a remote computer? Hmmm have to try that. I didn't think it worked that way.
_________________________
(... better days ahead)

Top
#133228 - 2005-02-01 06:17 PM Re: Is user member of local admin group
JazzM Offline
Getting the hang of it

Registered: 2004-04-23
Posts: 91
Right Allen. Check the membership remotely, not locally!
Tested both GroupMembers and Ingroup.
Cannot make Ingroup to work!.
However GroupMembers using host name instead of IP works fine for me.

Cheers Allan
_________________________
I will always look out from behind these eyes...

Top
#133229 - 2005-02-01 06:30 PM Re: Is user member of local admin group
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... we all know InGroup() cannot work and GroupMembers() does not overcome localized names.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#133230 - 2005-02-01 06:55 PM Re: Is user member of local admin group
JazzM Offline
Getting the hang of it

Registered: 2004-04-23
Posts: 91
well... a newbi as me didn't know...
However its always a pleasure to ask u guys, who always are so helpful and clever.

Once again thanx a lot!

_________________________
I will always look out from behind these eyes...

Top
#133231 - 2005-02-01 08:59 PM Re: Is user member of local admin group
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Win32Admin can lookup remote administraotr group names from localized OS's.

LocalAdminGrp(optional $Server)
Returns the name of the local BUILTIN\Administrators group on $Server.

This method is valuable when trying to locate a renamed or language localized group name. When $Server is NULL, the local computer is used. This method is valuable when trying to locate an account that has been renamed or is not 'Administrators' because of OS language localization.


_________________________
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
1 registered (Allen) and 581 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.062 seconds in which 0.023 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