Admin Detection

xbury.cs at clearstream.com xbury.cs at clearstream.com
Wed Aug 13 07:46:00 EDT 2003


On 12/08/2003 20:51:49 metacard-admin wrote:
>Has anyone come up with a way to determine the user privileges of the
>current user without writing a file to the drive?
>
>I'm trying to detect whether or not the current Windows user has Admin
>rights.  If the only way to determine this is to attempt to create a 
file,
>what is the best path to use?

Scott,

on NT4 or W2K only... (it would be nice if someone posted the osx and 
linux variants ;)

echo %username%
will give you the current user name.

Then, put the result in comparison with 
c:\net localgroup 
Choose the administrator group
net localgroup "administrators"
you should see your user name in there.

Alternatives:
In a NT domain, the local admin may be useless!
You can find the admins in net group "domain admins" -- but only from the 
PDC...
Unless you have EnterpriseAdmin (obsolete I believe) -- more below...


So one simple solution to find out if you are an administrator is this:
c:\>net sessions
System error 5 has occurred.

Access is denied.

or
c:\>net sessions

Computer               User name            Client Type      Opens Idle 
time

------------------------------------------------------------------------------
\\BELLINI                                   Windows NT 1381  0 00:07:10
The command completed successfully.


For enterprise admin

global EAAvailable 

  put shell("EA") into x
  put "The name specified is not recognized" is not in x into EAAvailable
  if not EAAvailable then answer "EA - Enterprise Administrator is 
required for this program to work. Maybe EA's path is not in your system's 
PATH environment variable."

on CheckUserIsAdmin
if EAAvailable  then
  local eainfo
  local marshalindomain,deputyindomain
  put shell("ea info") into eainfo
  -- parse this
  --   Marshal in Focus Domain?            Yes, Marshal with all Deputy 
powers
  --   Deputy in Focus Domain?             Yes
 
  put line lineoffset("Marshal in Focus Domain",eainfo) of eainfo into 
marshalindomain
  put line lineoffset("Deputy in Focus Domain",eainfo) of eainfo into 
deputyindomain
 
  get "yes" is in marshalindomain and "yes" is in deputyindomain
else
  get "access denied" is not in shell("net sessions")
end if
  return it
end CheckUserIsAdmin


Visit us at http://www.clearstream.com
                                                          
IMPORTANT MESSAGE

Internet communications are not secure and therefore Clearstream International does not accept legal responsibility for the contents of this message.

The information contained in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. Any views expressed in this e-mail are those of the individual sender, except where the sender specifically states them to be the views of Clearstream International or of any of its affiliates or subsidiaries.

END OF DISCLAIMER
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.runrev.com/pipermail/metacard/attachments/20030813/fc9c14c1/attachment.htm


More information about the metacard mailing list