windows admin or limited.

BlitzMax Forums/BlitzMax Beginners Area/windows admin or limited.

Jesse(Posted 2008) [#1]
is there a way to find out if a windows user has limited or admin rights on a computer?


Brucey(Posted 2008) [#2]
How's about

http://support.microsoft.com/kb/q118626/

and

http://msdn.microsoft.com/en-us/library/aa376389(VS.85).aspx


Jesse(Posted 2008) [#3]
thanks Brucey, but I think I need a little bit more help than that. I have no idea how to convert or adopt that to BMAX. My knowledge of c is far more limited.


kfprimm(Posted 2008) [#4]
Alright, the C code could be adapted to BlitzMax but it's easier to just use the sample's function. So,

admin.c


test.bmx


Give that a shot, I'm not sure it will work as I can't test it right now but that's the basic idea.


Jesse(Posted 2008) [#5]
thanks Khomy Prime, as soon as I work it out I'll let you know. Really apreciated.


Jesse(Posted 2008) [#6]
Khomy, I tried the code above but I get this errors:
C:/Documents and Settings/Jesse/My Documents/admin/.bmx/admin.c.console.release.win32.x86.o:admin.c:(.text+0x36): undefined reference to `AllocateAndInitializeSid@44'
C:/Documents and Settings/Jesse/My Documents/admin/.bmx/admin.c.console.release.win32.x86.o:admin.c:(.text+0x4b): undefined reference to `CheckTokenMembership'
C:/Documents and Settings/Jesse/My Documents/admin/.bmx/admin.c.console.release.win32.x86.o:admin.c:(.text+0x61): undefined reference to `FreeSid@4'
C:/Program Files/BlitzMax/lib/libmingw32.a(main.o):main.c:(.text+0x106): undefined reference to `WinMain@16'
Build Error: Failed to link C:/Documents and Settings/Jesse/My Documents/admin/admin.exe



kfprimm(Posted 2008) [#7]
Strange, ok, try adding,
#include <winbase.h>

after
#include <windows.h>

That should fix the first three errors.

The last error is a result of you trying to execute the C code directly. You have to save those two files in the same folder and compile/run test.bmx.


Jesse(Posted 2008) [#8]
it managed to clear those errors but now it doesn't seem to recognize:
"CheckTokenMembership" it apperst it is not defined in windows.h or winbase.h


Gabriel(Posted 2009) [#9]
Did anyone ever figure this out? I've just been trying to port the exact same example and I ended up with the exact same code, right down to including winbase.h but I'm also getting an undefined reference to "CheckTokenMembership".


Dabhand(Posted 2009) [#10]
Well, I ran into roughly the same problem with another Win32 function, found out if you change the '.c' file extension to '.cpp", you receive a different error about scope or something (Which means to me its managed to pick it up in Winbase.h)

After looking around for info about the new error, it seemed to resolve around paths, which, at the time, I was sick of looking and give up.

Dabz


Azathoth(Posted 2009) [#11]
You need to have '#define _WIN32_WINNT 0x500' before '#include <windows.h>'

Edit: fixed


Dabhand(Posted 2009) [#12]

You need to have '#define _WIN32_WINNT 0x500' before '#include <windows.h>'



*Fixed typo in quote!!! :D

Well knock me over with a deep wet pumper... That works! :)

Code archives... Quick! ;)

Dabz


Azathoth(Posted 2009) [#13]
*Fixed typo in quote!!! :D

Well knock me over with a deep wet pumper... That works! :)

Code archives... Quick! ;)

Dabz
You shouldn't need to though, the compiler should put in the correct value of the OS you're using.

Edit: Nevermind, seems like MinGW uses a default of 0x400 and Visual C++ uses a default 0x600


Dabhand(Posted 2009) [#14]
I was refering to the preprocessor directive bit, you have #defined, instead of just plain old #define

Ya little tinker! ;)

Dabz


Jesse(Posted 2009) [#15]
I did some research a while back and came to the conclusion that it was not included in MinGW so I left it alone. Thanks for that guys.

I think there is something wrong with my MingGW when I compile it with '.cpp' I get this:
BC:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.cpp:1:2: invalid preprocessing directive #Include
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.cpp:2:2: invalid preprocessing directive #Include
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.cpp:3: error: `Int' does not name a type
Build Error: failed to compile C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.cpp


when I use c I get this:
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:2:2: invalid preprocessing directive #Include
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:3:2: invalid preprocessing directive #Include
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:4: error: syntax error before "IsUserAdmin"
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c: In function `IsUserAdmin':
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:6: error: `BOOL' undeclared (first use in this function)
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:6: error: (Each undeclared identifier is reported only once
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:6: error: for each function it appears in.)
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:6: error: syntax error before "b"
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:7: error: `SID_IDENTIFIER_AUTHORITY' undeclared (first use in this function)
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:8: error: `PSID' undeclared (first use in this function)
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:9: error: `b' undeclared (first use in this function)
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:10: error: `NtAuthority' undeclared (first use in this function)
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:12: error: `SECURITY_BUILTIN_DOMAIN_RID' undeclared (first use in this function)
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:13: error: `DOMAIN_ALIAS_RID_ADMINS' undeclared (first use in this function)
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:15: error: `AdministratorsGroup' undeclared (first use in this function)
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:17: error: syntax error before '{' token
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c: At top level:
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:23: error: syntax error before '}' token
C:/Documents and Settings/Chuyin/Desktop/limited/limitedadmin.c:26: error: syntax error before '}' token


does anybody else get that or am I doing something wrong?


Dabhand(Posted 2009) [#16]
It works for me, try my code just in case:-

http://www.denathorn.co.uk/files/test.zip

EDIT: When I say my code, I mean that code above, but what I used /ramble

Dabz


Gabriel(Posted 2009) [#17]
Yep, works fine here too. Cheers Dabz.


Jesse(Posted 2009) [#18]
Dabhand what version of MingGW are using? I get the same error as my previous to last post. My version is 3.4.2
C:/Documents and Settings/Chuyin/Desktop/test/.bmx/admin.c.release.win32.x86.o:admin.c:(.text+0x4b): undefined reference to `CheckTokenMembership'



Dabhand(Posted 2009) [#19]
When I 'g++ --version' it, it spits out version 3.4.5

Dabz


Jesse(Posted 2009) [#20]
I will update. see if that fixes it.


Gabriel(Posted 2009) [#21]
I'm also using 3.4.5 so that does seem to be the solution.


REDi(Posted 2009) [#22]
Jesse, it looks to me like the blitzmax syntax highlighter has messed it up for you, try and copy and paste it again.


Azathoth(Posted 2009) [#23]
does anybody else get that or am I doing something wrong?
Don't use MaxIDE to create the c files as C/C++ is case sensitive and MaxIDE is changing the casing of recognized keywords.


Jesse(Posted 2009) [#24]
*smacks self on forehead* yes thanks. How bad is my memory, I now recall Brucey helped me with that same problem a while back.


Dabhand(Posted 2009) [#25]
I sometimes wish BlitzMax was case sensitive, I prefer that to be honest!

No reason really! :P

Dabz


Jesse(Posted 2009) [#26]
after 2 atempts at installing it to a diferent directory and getting all kinds of errors I desided to install it to the default and finally got it working.
my original problem was a result of the wrong MinGW version.

Thanks all.

I sometimes wish BlitzMax was case sensitive, I prefer that to be honest!


not me, I am too lazy :). I recall it used to have that when I bought blitz basic years back. I don't miss it.