Page 1 of 2 12>
Topic Options
#142405 - 2005-06-27 06:22 AM INGROUP issue
daniel1982 Offline
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
#142406 - 2005-06-27 08:43 AM Re: INGROUP issue
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Maybe try this type of code and see how it works out for you.


$Admin=IIf(InGroup(@WKSTA+'\'+SidToName('S-1-5-32-544'))-1+@INWIN=1,1,0)

If $Admin
   ;do something
EndIf
 

Top
#142407 - 2005-06-27 11:27 AM Re: INGROUP issue
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
_________________________
!

download KiXnet

Top
#142408 - 2005-06-28 01:46 AM Re: INGROUP issue
daniel1982 Offline
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
#142409 - 2005-06-28 02:07 AM Re: INGROUP issue
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, he took the code from one udf.
it is enough for you to know that it returns 1 if the user is local admin.
otherwise it returns 0.

if you need more explanation, check in:
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB12&Number=83341
_________________________
!

download KiXnet

Top
#142410 - 2005-06-28 02:09 AM Re: INGROUP issue
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
specially http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB12&Number=83344#Post83344
which is the explanation part...
_________________________
!

download KiXnet

Top
#142411 - 2005-06-28 02:19 AM Re: INGROUP issue
Chris S. Offline
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
#142412 - 2005-06-28 02:21 AM Re: INGROUP issue
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
...but you failed to explain the Immediate IF part!
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#142413 - 2005-06-28 02:26 AM Re: INGROUP issue
Chris S. Offline
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
#142414 - 2005-06-28 02:33 AM Re: INGROUP issue
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I was hoping for an explanation for the IIF cuz it makes no sense to me.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#142415 - 2005-06-28 02:45 AM Re: INGROUP issue
Chris S. Offline
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
#142416 - 2005-06-28 02:52 AM Re: INGROUP issue
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I understand that much. I just don't see the difference using IIF. Just wondering why the added complexity.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#142417 - 2005-06-28 02:54 AM Re: INGROUP issue
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Ja, I agree. I don't think it is needed.
Top
#142418 - 2005-06-28 03:04 AM Re: INGROUP issue
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yes, indeed!
and in the original code there was none.
doc, why you altered it?
wasn't the udf easy enough to use?
_________________________
!

download KiXnet

Top
#142419 - 2005-06-28 03:38 AM Re: INGROUP issue
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
So that I could upset all of you perfectionists
Top
#142420 - 2005-06-28 04:07 AM Re: INGROUP issue
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
perf...?
I thought the word was anal?!?
_________________________
!

download KiXnet

Top
#142421 - 2005-09-08 09:06 AM Re: INGROUP issue
daniel1982 Offline
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
#142422 - 2005-09-08 12:07 PM Re: INGROUP issue
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
take out the @wksta part.

that is, what does this say:
Code:

"if admin, will print 1: "
InGroup(SidToName('S-1-5-32-544')) ;doc, the iif is useless in here.



that sid is local administrators sid so, it should return local sid and on DC the domains local admins.
well, can't test it as have some "issues" here so, let me know.
_________________________
!

download KiXnet

Top
#142423 - 2005-09-08 03:24 PM Re: INGROUP issue
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
IIRC there may be an issue with the token cache when a PC is renamed. Just delete the reg key.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#142424 - 2005-09-08 09:53 PM Re: INGROUP issue
NTDOC Administrator Offline
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
Page 1 of 2 12>


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

Who's Online
0 registered and 202 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.192 seconds in which 0.138 seconds were spent on a total of 13 queries. Zlib compression enabled.

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