j95661
(Getting the hang of it)
2004-07-16 07:28 AM
faster ingroup "local admins"

For some time now I have been using ingroup in my login script to determine Local Administrative rights. For some reason in our enviornment ingroup takes a considerable amount of time especially at remote locations. After digging into my old batch goodie bag I came up with the following section to add to my script. It has made a tremendous difference for determining local administrative rights. If your enviornment doesnt add users to the local administrators group you wont see any difference.

Code:
 

Shell '%comspec% /c net localgroup administrators | find /i "@USERID" > nul'
If @error = 0
$LoAdmin = "TRUE"
Else
If InGroup("\\" + @WKSTA + "\Administrators") = 1
$LoAdmin = "TRUE"
EndIf
EndIf




Howard Bullock
(KiX Supporter)
2004-07-16 01:56 PM
Re: faster ingroup "local admins"

From 4.x on ingroup checks global group membership from the user's authentication token and also has a local registry cache. Previous versions always made a roundtrip to a server or DC. What version of KiXtart are you using?

Also, have you triedsomething like:

Code:
	$Admin = 1
If not InGroup( "\\" + @wksta + "\" + SidToName( "S-1-5-32-544" ) )
$Admin=0
Endif



LonkeroAdministrator
(KiX Master Guru)
2004-07-16 02:25 PM
Re: faster ingroup "local admins"

did you mean:
Code:

$Admin = InGroup( @wksta + "\" + SidToName( "S-1-5-32-544" ) )



just had to golf...


Kdyer
(KiX Supporter)
2004-07-16 03:12 PM
Re: faster ingroup "local admins"

And... This is talked about in the Best Known Methods FAQ right here!

Kent


Howard Bullock
(KiX Supporter)
2004-07-16 08:04 PM
Re: faster ingroup "local admins"

Yeah that's what I meant. Old code...Can I send all my code up there for optimization?

LonkeroAdministrator
(KiX Master Guru)
2004-07-17 05:32 AM
Re: faster ingroup "local admins"

sure.

Sealeopard
(KiX Master)
2004-07-18 05:50 PM
Re: faster ingroup "local admins"

Or Jooel could release his Automated KiXtart Code Optimizer UDF.