|
Home > Archive > dBASE Windows API > April 2005 > Admin Rights or NOT?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Admin Rights or NOT?
|
|
| Heinz Kesting 2005-04-19, 8:24 pm |
| Hi everybody,
How can be determined if the current user has logged into Windows (NT4, 2000
and XP) with ADMIN rights or not?
Thanks in advance, Heinz
| |
| Jim Sare [dBVIPS] 2005-04-20, 8:24 pm |
| Heinz,
> How can be determined if the current user has logged into Windows (NT4, 2000
> and XP) with ADMIN rights or not?
You can try this WinAPI approach:
extern CLOGICAL IsUserAnAdmin() shell32
? IsUserAnAdmin()
The function is documented on MSDN as available in shell32.dll v5.00 or
later. But it is also restricted to Win 2K/XP or later. I _thought_ that
shell32.dll v5.00 or later was also available for NT4.0 with later
versions of Internet Explorer, which means it _should_ work there as
well. I don't have an NT system here currently to test it. You might
want to test it on NT as well if you need to use it there.
Hope it helps.
--
Jim Sare - [dBVIPS]
http://www.jimsare.com
| |
| Ivar B. Jessen 2005-04-20, 8:24 pm |
| On Wed, 20 Apr 2005 15:40:45 -0400, "Jim Sare [dBVIPS]"
<jimsare@yahoo.com> wrote:
>extern CLOGICAL IsUserAnAdmin() shell32
>? IsUserAnAdmin()
In Win2000 Sp4/IE6 SP1 the result of,
extern CLOGICAL IsUserAnAdmin() shell32
is,
Alert
Error: Procedure not found: IsUserAnAdmin
Ivar B. Jessen
| |
| Heinz Kesting 2005-04-20, 8:24 pm |
| Hi Jim
> You can try this WinAPI approach:
>
> extern CLOGICAL IsUserAnAdmin() shell32
> ? IsUserAnAdmin()
>
> The function is documented on MSDN as available in shell32.dll v5.00 or
> later. But it is also restricted to Win 2K/XP or later. I _thought_ that
> shell32.dll v5.00 or later was also available for NT4.0 with later
> versions of Internet Explorer, which means it _should_ work there as
> well. I don't have an NT system here currently to test it. You might
> want to test it on NT as well if you need to use it there.
Currently I'm using a w2k system, but get the same error as Ivar reports:
Procedure not found: IsUserAnAdmin
I looked in the WinAPI help and couldn't find a keyword like this neither.
My Shell32.dll is version 5.0.3700.6705, however, the files shlobj.h and
shell32.lib (mention on MSDN) don't seem to be on my machine.
What's wrong here?
Thanks for helping, Heinz
| |
| Rick Miller 2005-04-20, 8:24 pm |
| "Jim Sare [dBVIPS]" <jimsare@yahoo.com> wrote in
news:V0QmMDeRFHA.1528@news-server:
> Heinz,
>
>
> You can try this WinAPI approach:
>
> extern CLOGICAL IsUserAnAdmin() shell32
> ? IsUserAnAdmin()
----
might need the CVOID in the parens.
extern CLOGICAL IsUserAnAdmin(CVOID)
shell32 from "IsUserAnAdmin"
Rick Miller
| |
| Heinz Kesting 2005-04-20, 8:24 pm |
| Hi Rick
> might need the CVOID in the parens.
>
> extern CLOGICAL IsUserAnAdmin(CVOID)
shell32 from "IsUserAnAdmin"
That's producing the very same error, unfortunately.
Thanks for helping, Heinz
| |
| Rick Miller 2005-04-20, 8:24 pm |
| "Heinz Kesting" <hekesting AT web DOT de> wrote in news:ZqMwgAfRFHA.320
@news-server:
> Hi Rick
>
>
> That's producing the very same error, unfortunately.
----
OK.
? IsUserAnAdmin() // returns true/false
Works fine here.
Rick Miller
| |
| Jim Sare [dBVIPS] 2005-04-20, 8:24 pm |
| Ivar,
> In Win2000 Sp4/IE6 SP1 the result of,
As I mentioned in my previous posting:
"The function is documented on MSDN as available in shell32.dll v5.00 or
later."
If you go to the Mickeysoft DLL Help Database at:
http://http://support.microsoft.com/dllhelp/
and conduct a search "By File Only" for shell32.dll, you can see that
shell32.dll v5.0.2920.0 is distributed with 2K Pro and 2K Server. Also,
v5.0.3103.1000 is distributed with 2K SP1. So _if_ your system has been
installed and updated correctly, I would expect the proper version of
shell32.dll to be on your system. I would have no idea why it might not
be on your system. Or maybe the DLL Help Database is in error. I would
recommend checking for multiple copies of shell32.dll on your system,
and the versions of each copy.
Hope it helps.
--
Jim Sare - [dBVIPS]
http://www.jimsare.com
| |
| Jim Sare [dBVIPS] 2005-04-20, 8:24 pm |
| Heinz,
> Currently I'm using a w2k system, but get the same error as Ivar reports:
>
> Procedure not found: IsUserAnAdmin
Please see my response to Ivar in this thread regarding this.
> I looked in the WinAPI help and couldn't find a keyword like this neither.
It won't be in the WinAPI help. The WinAPI help only documents the
functions in the base WinAPI, and not the mass of extensions to the
WinAPI, of which the shell facility is but one of the mass. For a
complete listing of the Windows Shell functions, go to:
http://msdn.microsoft.com/library/d...UserAnAdmin.asp
and you will see a full listing of shell functions in the left pane of
the browser.
> My Shell32.dll is version 5.0.3700.6705,
The IsUserAnAdmin should be in that dll file. Most likely you have
multiple copies of shell32.dll on the system and an earlier version of
the file is being loaded instead of the latest. Or possibly the MSDN
documentation on IsUserAnAdmin is in error, and in reality maybe
IsUserAnAdmin is only available on Win2K Server. But I'm guessing you
have multiple copies of shell32.dll on your system. Shell32.dll is a
redistributable file, and many other applications attempt to
update/replace shell32.dll with what they think is the correct version
for their app, and essentially (and incorrectly) 'downgrade' the file to
something older.
> however, the files shlobj.h and
> shell32.lib (mention on MSDN) don't seem to be on my machine.
You won't have shlobj.h on the system unless you either install a C++ or
Delphi or whatever compiler on the system, or you install the Window SDK
(Software Development Kit) which is downloadable from Mickeysoft. But
you don't need shlobj.h to use the IsUserAnAdmin function. Shlobj.h is
simply a header file which contains constantants and function
definitions and a bunch of other junk which mostly can't be used (and
isn't necessary) in dBASE. The only thing you typically need would be
any constants associated with a particular function. And IsUserAnAdmin
does not use/require any constants. So you don't need the shlobj.h
header file to use the function.
Shell32.lib is a compiler output file containing object code. The .lib
file would be used by a linker _if_ you were linking an executable which
used shell functions in an application built using C++ or whatever. The
..lib files are totally unuseable and unnecessary in dBASE.
BTW, the MSDN documentation is correct about IsUserAnAdmin not being
available on NT. According to additional MSDN documentation research and
the DLL Help Database, Shell32 v5.00 or later is not distributed to NT
systems. In particular, see:
http://msdn.microsoft.com/library/d...de/versions.asp
and specifically read "Note 3:"
--
Jim Sare - [dBVIPS]
http://www.jimsare.com
| |
| Jim Sare [dBVIPS] 2005-04-20, 8:24 pm |
| Rick,
> might need the CVOID in the parens.
>
> extern CLOGICAL IsUserAnAdmin(CVOID)
shell32 from "IsUserAnAdmin"
Nope. The CVOID option is only required on the _return_ value side if a
function does not have a return value. For example, to prototype
GdiplusShutdown:
extern CVOID GdiplusShutdown(; // void GdiplusShutdown
CPTR CULONG); // ULONG_PTR token
gdiplus.dll
The function GdiplusShutdown does not return any value. Here, CVOID is
required to tell dBASE that GdiplusShutdown does not return a value.
On the parameter side when a function accepts no inputs as is the case
with IsUserAnAdmin, CVOID is unnecessary and superfluous if the function
does not accept any inputs. It's not needed, but it is optional. dBASE
will handle it the same either with or without CVOID on the input side.
--
Jim Sare - [dBVIPS]
http://www.jimsare.com
| |
| Rick Miller 2005-04-20, 8:24 pm |
| Hello Jim,
"Jim Sare [dBVIPS]" <jimsare@yahoo.com> wrote in
news:disUTfgRFHA.432@news-server:
> Rick,
>
>
> Nope. The CVOID option is only required on the _return_ value side
> if a function does not have a return value. For example, to
> prototype GdiplusShutdown:
>
> extern CVOID GdiplusShutdown(; // void GdiplusShutdown
> CPTR CULONG); // ULONG_PTR token
> gdiplus.dll
>
----
I noticed that, and was surprised.
Thanks for explaining,
Rick Miller
| |
| Heinz Kesting 2005-04-21, 3:24 am |
| Hi Jim and Rick,
As it is definitel not working with NT4, I'll have to use something else.
In the dbasetalk.programming group I got an reply to my original post which
is working on NT4 and higher, so I'm going to turn to that.
? isLocalAdmin()
function isLocalAdmin
oNet = new OleAutoClient("WScript.Network")
TestShare = "\\" + oNet.ComputerName + "\admin$\*.*"
release object oNet
return (new array().dir(TestShare)>0)
However, if it had worked with NT4, the API approach would have been my
favorite.
Anyway, thanks for helping!
Kind regards, Heinz
| |
| Ivar B. Jessen 2005-04-21, 3:24 am |
| On Wed, 20 Apr 2005 18:26:22 -0400, "Jim Sare [dBVIPS]"
<jimsare@yahoo.com> wrote:
>
>As I mentioned in my previous posting:
>
>"The function is documented on MSDN as available in shell32.dll v5.00 or
>later."
>
>If you go to the Mickeysoft DLL Help Database at:
>http://http://support.microsoft.com/dllhelp/
>
>and conduct a search "By File Only" for shell32.dll, you can see that
>shell32.dll v5.0.2920.0 is distributed with 2K Pro and 2K Server. Also,
>v5.0.3103.1000 is distributed with 2K SP1.
I have shell32.dll version 5.0.3700.6705 Language: Danish
>So _if_ your system has been
>installed and updated correctly, I would expect the proper version of
>shell32.dll to be on your system.
I recently installed Win2000/SP2 on a new HD and updated to Win200 SP4
via MS live update.
>I would have no idea why it might not
>be on your system. Or maybe the DLL Help Database is in error. I would
>recommend checking for multiple copies of shell32.dll on your system,
>and the versions of each copy.
There is a copy in folder 'ServicePackFiles', and in folder
'$NTServicepackUnsta
ll$' there is a version 5.0.3315.2902 Language:
Danish.
Ivar B. Jessen
| |
| Jim Sare [dBVIPS] 2005-04-21, 8:24 pm |
| Heinz,
> However, if it had worked with NT4, the API approach would have been my
> favorite.
Yes...the API approach would have been more direct and much quicker.
There probably is a way using API that would be quicker and with less
overhead than WSH. But I haven't figured out what that might be...yet.<g>
> Anyway, thanks for helping!
My pleasure. In the end, you have something that works.
--
Jim Sare - [dBVIPS]
http://www.jimsare.com
| |
| Jim Sare [dBVIPS] 2005-04-21, 8:24 pm |
| Ivar,
> I have shell32.dll version 5.0.3700.6705 Language: Danish
There's no mention in the docs of the function being language-dependent
or anything like that. And I wouldn't anticipate that it would be
language-dependent.
> I recently installed Win2000/SP2 on a new HD and updated to Win200 SP4
> via MS live update.
> There is a copy in folder 'ServicePackFiles', and in folder
> '$NTServicepackUnsta
ll$' there is a version 5.0.3315.2902 Language:
> Danish.
I'm honestly stumped.<g> All the documented ingredients appear to be
there on your system. I haven't deployed anything that uses the function
so I only have play/test experience to draw from.
You might try downloading one of the dll 'snooper' utilities (there's
tons of 'em on the web) and peek at shell32.dll on your system to see if
it's actually exporting IsUserAnAdmin. If the function is actually
exported from the dll, then most likely there's something really weird
going on in dBASE where it can't 'see' the function...which I've never
seen happen before. If the dll isn't exporting the function, then the
Mickeysoft docs are wrong...at least as they relate to shell32.dll on
Win2K. Wouldn't be the first time.<g>
I wish I had a Win2K system here to test. I won't have that opportunity
until my daughter comes home from college for the summer break with her
laptop about 3 weeks from now.<g> That's the only Win2K system I have
available to me currently.
If you figure it out, I'd love to hear about what the problem was.
--
Jim Sare - [dBVIPS]
http://www.jimsare.com
| |
| Ivar B. Jessen 2005-04-22, 3:24 am |
| On Thu, 21 Apr 2005 17:20:22 -0400, "Jim Sare [dBVIPS]"
<jimsare@yahoo.com> wrote:
>
>There's no mention in the docs of the function being language-dependent
>or anything like that. And I wouldn't anticipate that it would be
>language-dependent.
>
>
>I'm honestly stumped.<g> All the documented ingredients appear to be
>there on your system. I haven't deployed anything that uses the function
>so I only have play/test experience to draw from.
What is the version of shell32.dll you have installed? Have you found
any description of the function on MSDN?
>
>You might try downloading one of the dll 'snooper' utilities (there's
>tons of 'em on the web) and peek at shell32.dll on your system to see if
>it's actually exporting IsUserAnAdmin. If the function is actually
>exported from the dll, then most likely there's something really weird
>going on in dBASE where it can't 'see' the function...which I've never
>seen happen before. If the dll isn't exporting the function, then the
>Mickeysoft docs are wrong...at least as they relate to shell32.dll on
>Win2K. Wouldn't be the first time.<g>
Using QuickViewPlus I can see all function names in the dll.
IsUseAnAdmin is not found. Neither are the words 'User' or 'Admin'.
Can you recommend a better snooper utility?
>
>I wish I had a Win2K system here to test. I won't have that opportunity
>until my daughter comes home from college for the summer break with her
>laptop about 3 weeks from now.<g> That's the only Win2K system I have
>available to me currently.
>
>If you figure it out, I'd love to hear about what the problem was.
The function does not exist <g>
Ivar B. Jessen
| |
| Jim Sare [dBVIPS] 2005-04-22, 3:24 am |
| Rick,
> Thanks for explaining,
My pleasure.
You mentioned that IsUserAnAdmin worked for you. Was that on 2K or XP?
--
Jim Sare - [dBVIPS]
http://www.jimsare.com
| |
| Jim Sare [dBVIPS] 2005-04-22, 3:24 am |
| Ivar,
> What is the version of shell32.dll you have installed?
6.0.2800.1613
All XP systems have shell32.dll v6.x installed I believe.
> Have you found any description of the function on MSDN?
Yes. I provided the exact URL for it in my reply to Heinz yesterday.
Here it is again:
http://msdn.microsoft.com/library/d...UserAnAdmin.asp
> Using QuickViewPlus I can see all function names in the dll.
> IsUseAnAdmin is not found. Neither are the words 'User' or 'Admin'.
QVP should be fine. I've used it for years.
> Can you recommend a better snooper utility?
Nope. I've never needed a better one.<g>
> The function does not exist <g>
I guess dBASE didn't lie when it said "Procedure not found". Looks like
maybe the Mickeysoft docs have a bug then.<g> Typical...one can't
believe most of what one reads.<g>
--
Jim Sare - [dBVIPS]
http://www.jimsare.com
| |
| Ivar B. Jessen 2005-04-22, 3:24 am |
| On Fri, 22 Apr 2005 02:39:03 -0400, "Jim Sare [dBVIPS]"
<jimsare@yahoo.com> wrote:
>
>I guess dBASE didn't lie when it said "Procedure not found". Looks like
>maybe the Mickeysoft docs have a bug then.<g> Typical...one can't
>believe most of what one reads.<g>
I submitted a bug report to MS which promises an answer within 24
hours.
Maybe they meant shell32.dll version _6.0_ or higher :-)
Ivar B. Jessen
| |
| Rick Miller 2005-04-22, 9:24 am |
| Hello Jim,
"Jim Sare [dBVIPS]" <jimsare@yahoo.com> wrote in
news:UX8mHXwRFHA.444@news-server:
> Rick,
>
> You mentioned that IsUserAnAdmin worked for you. Was that on 2K or
> XP?
----
Worked on XP with SP2
shell32.dll 6.0.2900.2620.
Did not work on 2K with SP4,
shell32.dll 5.0.3700.6705.
The docs may have an error <g>.
Rick Miller
| |
| Jim Sare [dBVIPS] 2005-04-22, 11:23 am |
| Rick,
> The docs may have an error <g>.
It appears so.<g>
Thanks.
--
Jim Sare - [dBVIPS]
http://www.jimsare.com
|
|
|
|
|