#142405 - 2005-06-27 06:22 AM
INGROUP issue
|
daniel1982
Getting the hang of it
Registered: 2005-03-23
Posts: 77
Loc: Sydney, Australia
|
Hi all,
I have a quick question about INGROUP... I'm using it like this:
Code:
If InGroup(@WKSTA + "\Administrators") <> 1 $=MessageBox("You must be a member of the Administrators group to run this script.", $ProgramTitle, 32) Exit EndIf
Which works nine times out of 10. Occasionaly however, a user will ring and say that they cannot open the script as they are getting the above error message and quitting out. At times another user with membership to the same groups has tried and it has worked fine.
Does anyone have any ideas on why this is happening? I'm trying to check the local Administrators group on the workstation they are running on. This group contains global domain groups such as Domain Admins etc.
Daniel
|
Top
|
|
|
|
#142408 - 2005-06-28 01:46 AM
Re: INGROUP issue
|
daniel1982
Getting the hang of it
Registered: 2005-03-23
Posts: 77
Loc: Sydney, Australia
|
Hi NTDOC,
do you mind explaining a little what you have done? 'S-1-5-32-544' is the SID of the Local Administrators group? Why do you minus 1?
Also what does @INWIN=1,1,0 do? I know @INWIN returns a code depending on what operating system is running, but what does the 1,1,0 do?
thanks for your help! cheers, Daniel
|
Top
|
|
|
|
#142410 - 2005-06-28 02:09 AM
Re: INGROUP issue
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
|
Top
|
|
|
|
#142411 - 2005-06-28 02:19 AM
Re: INGROUP issue
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Here's an explanation I just came up with...
Code:
; Here is the whole statement IIf(InGroup(@WKSTA+'\'+SidToName('S-1-5-32-544'))-1+@INWIN=1,1,0) ? ; Now let's break it down... ; Using SidToName to return the name of the Administrators Group SidToName('S-1-5-32-544') ? ; Is the user a member of the Administrators group? InGroup(@WKSTA+'\'+SidToName('S-1-5-32-544')) ? ; If no the result will be 0, if yes the result is 1 ; Now, substract 1; so no = -1 and yes = 0 InGroup(@WKSTA+'\'+SidToName('S-1-5-32-544'))-1 ? ; @INWIN returns '1' for NT and '2' for 9x @INWIN ? ; If 9x: 0 + -1 + 2 = 1 ; If NT (non admin): 0 + -1 + 1 = 0 ; If NT (admin): 1 + -1 + 1 = 1
Edited by Chris S. (2005-06-28 02:21 AM)
|
Top
|
|
|
|
#142413 - 2005-06-28 02:26 AM
Re: INGROUP issue
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Now that you mention it, I don't think it is needed. The result of... Code:
InGroup(@WKSTA+'\'+SidToName('S-1-5-32-544'))-1+@INWIN ...should suffice.
|
Top
|
|
|
|
#142415 - 2005-06-28 02:45 AM
Re: INGROUP issue
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Well, you could say...
Code:
If InGroup(@WKSTA+'\'+SidToName('S-1-5-32-544'))-1+@INWIN = 1 "Result is TRUE (1)" ? Else "Result is FALSE (0)" ? EndIf
|
Top
|
|
|
|
#142419 - 2005-06-28 03:38 AM
Re: INGROUP issue
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11625
Loc: CA
|
So that I could upset all of you perfectionists
|
Top
|
|
|
|
#142421 - 2005-09-08 09:06 AM
Re: INGROUP issue
|
daniel1982
Getting the hang of it
Registered: 2005-03-23
Posts: 77
Loc: Sydney, Australia
|
Hi all,
This same issue has come up again, this time on a pc I was running the script on. I've done a little more investigation, and I think I've found the root cause of the problem (at least in this instance).
The workstation's original name was VMW2K (it's a virtual machine), however I needed to change it on the network as a collegue of mine copied the virtual machine, and hence took the VMW2K workstation name. I changed it to VMW2K2. So currently, on the network it is named VMW2K2, but the "My computer icon" displays VMW2K.
Although my login belongs to a (domain) group that is a local administrator on the machine, I got the same error, saying I was not an administrator. I used enumgroup to find all the groups I was a member of, and the administrator group was returned as "VMW2K\Administrators". The script tests if you are a member of '@WKSTA + "\Administrators"' group, however the value of @WKSTA is "VMW2K2".
I'm not sure if this is a bug with @WKSTA or Ingroup, or if it's a problem with my script. Does anyone have any suggestions?
Cheers, Daniel
|
Top
|
|
|
|
#142424 - 2005-09-08 09:53 PM
Re: INGROUP issue
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11625
Loc: CA
|
Quote:
InGroup(SidToName('S-1-5-32-544')) ;doc, the iif is useless in here.
So I see it still upsets you, so I've done my job well
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 202 anonymous users online.
|
|
|