PC Review


Reply
Thread Tools Rate Thread

check user groups

 
 
powtrix
Guest
Posts: n/a
 
      11th Jul 2007
Hi,
is possible to verify if an user is in administrators group, ex.:

IF %username% "isin" "%COMPUTERNAME%\Administrators" do (
...
)
or "DOMAIN\Domain Admins"..

Because I want to run some commands at netlogon script only if the
user is a local administrator.
thank you.

 
Reply With Quote
 
 
 
 
Matt Williamson
Guest
Posts: n/a
 
      11th Jul 2007
> Hi,
> is possible to verify if an user is in administrators group, ex.:
>
> IF %username% "isin" "%COMPUTERNAME%\Administrators" do (
> ...
> )
> or "DOMAIN\Domain Admins"..
>
> Because I want to run some commands at netlogon script only if the
> user is a local administrator.
> thank you.


There is a utility IFMEMBER that does what you're looking for. Search the MS
website for it.


 
Reply With Quote
 
Al Dunbar
Guest
Posts: n/a
 
      12th Jul 2007

"Matt Williamson" <(E-Mail Removed)> wrote in message
news:Btcli.6265$lY4.775@trndny07...
>> Hi,
>> is possible to verify if an user is in administrators group, ex.:
>>
>> IF %username% "isin" "%COMPUTERNAME%\Administrators" do (
>> ...
>> )
>> or "DOMAIN\Domain Admins"..
>>
>> Because I want to run some commands at netlogon script only if the
>> user is a local administrator.
>> thank you.

>
> There is a utility IFMEMBER that does what you're looking for. Search the
> MS website for it.


Note that the IFMEMBER utility may only test for an account's direct
membership, whereas actual administratorship can be inherited through group
nesting but not be detectable by IFMEMBER.

/Al


 
Reply With Quote
 
powtrix
Guest
Posts: n/a
 
      12th Jul 2007
found a way that works without addon

@echo off
net localgroup administradores | find /i "%username%"
if "%errorlevel%"=="1" (
echo usuario "%username%" NON eh administrador
goto:eof
) else (
echo usuario "%username%" eh administrador
call \\server\netlogon\updates.cmd
)


notes:
users/groups are in portuguese as well.

tks ^D

 
Reply With Quote
 
Al Dunbar
Guest
Posts: n/a
 
      14th Jul 2007

"powtrix" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> found a way that works without addon
>
> @echo off
> net localgroup administradores | find /i "%username%"
> if "%errorlevel%"=="1" (
> echo usuario "%username%" NON eh administrador
> goto:eof
> ) else (
> echo usuario "%username%" eh administrador
> call \\server\netlogon\updates.cmd
> )


This will certainly flag any user that is a direct member of the
administrators group, however, it will miss anyone who is a member of a
domain group that is a member of administrators. It will also register false
positives. Here is the output from my own computer:

C:\Documents and Settings\Al>net localgroup administrators
Alias name administrators
Comment Administrators have complete and unrestricted access to
the compu
ter/domain

Members

-------------------------------------------------------------------------------
Administrator
admAl
The command completed successfully.

Given that my normal account is Al and my admin account is admAl, both will
appear to be administrators. Also, usernames such as Ali, Strat, men, mem,
comma, sfu, and etc will also be falsely flagged as administrator when
clearly they are not (at least not on my machine).

/Al


 
Reply With Quote
 
powtrix
Guest
Posts: n/a
 
      19th Jul 2007
yes, this is fine for me:

:ADMLOCAL
NET LOCALGROUP Administradores | FIND /I "%USERNAME%" > NUL && GOTO
INI || GOTO ADMDOM

:ADMDOM
NET GROUP "Domain Admins" /DOMAIN | FIND /I "%USERNAME%" > NUL && GOTO
INI || GOTO :EOF

:INI
echo admin user active [%username%].


tks__
powtrix


>
> Given that my normal account is Al and my admin account is admAl, both will
> appear to be administrators. Also, usernames such as Ali, Strat, men, mem,
> comma, sfu, and etc will also be falsely flagged as administrator when
> clearly they are not (at least not on my machine).
>
> /Al



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
domain name is missing when adding a user in Local user and groups. gchandrujs via WindowsKB.com Windows XP General 0 8th Sep 2007 04:30 PM
Program Groups based on user groups? Matt Windows XP Customization 2 30th Jul 2005 10:11 PM
User Properties/Member Of/Select Groups - groups not listed =?Utf-8?B?QW5kcmV3IEZpdmlhbg==?= Windows XP General 0 27th Jan 2004 05:16 PM
Restricted Groups. Adding user to Power User Paul Banco Microsoft Windows 2000 Group Policy 1 8th Oct 2003 06:29 PM
Groups Policy to assign user to Local Machine Power Users Groups. KA Kueh Microsoft Windows 2000 Group Policy 3 19th Sep 2003 07:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:46 AM.