WINAMP.COM | Forums > Developer Center > NSIS Discussion > Check a user has a certain permission |
Last Thread
Next Thread
|
| Author |
|
|
RobGrant Senior Member
Registered: Sep 2004 |
Check a user has a certain permission
Hi guys __________________ |
||
|
|
|
kichik M.I.A. [NSIS Dev, Mod]
Registered: Oct 2001 |
You can call LsaEnumerateAccountRights or you can try using this privilege in the installer to see if it's granted already. I don't know of any plug-in that already does that. __________________ |
||
|
|
|
RobGrant Senior Member
Registered: Sep 2004 |
Hm, yes I see. That seems reasonably involved, is there anyone with more experience of calling Windows API functions that could have a look at this for me? __________________ |
||
|
|
|
CancerFace Senior Member
Registered: Apr 2006 |
I am also interested in this. It involves allocation of an Lsa policy handle, something which I have been trying to do for a while now without any success, as stated in this thread. The above code will not work for the LsaOpenPolicy handle and I do not know why. The LsaEnumerateAccountRights function will give you an array of structures that have the format listed here and the trick is to pay attention that the structures accept the sizes in bytes.code: Hope this helps as a starting point ... Last edited by CancerFace on 04-26-2006 at 11:27 AM |
||
|
|
|
CancerFace Senior Member
Registered: Apr 2006 |
If it were not for kitchik's input in this thread I wouldn't be able to write this $R3 in the above code will hold the number of enumerated privileges in the array found in $R2. You can pull the privilleges out by callingcode: for the first structure, then calculate its size, advance to the next buffer ($R2 + size of first structure) and call it again. Repeat $R3 times ... The names of the privilleges are listed in NTSecAPI.hcode: CF |
||
|
|
|
RobGrant Senior Member
Registered: Sep 2004 |
Hmm, thanks for that code, it looks ace, but I'm not sure how to carry on in the way you say. I'm not too au fait with how to finish this off to find the SE_SERVICE_LOGON_NAME privilege. __________________ |
||
|
|
|
CancerFace Senior Member
Registered: Apr 2006 |
Between the code that I posted on my previous reply and this MSDN page you should get an idea of what you're after. The definitions of the privileges are found in NTSecAPI.h of the windows SDK. Here are the basic ones straight out of that file: so if I am reading this right, when you enumerate the privileges, you should end up with an array of LSA_UNICODE_STRING structures and each one contains one privilege, such as SeServiceLogonRight (which is the SE_SERVICE_LOGON_NAME privilege that you're after).code: In your case, one of the elements of the array will contain the SeServiceLogonRight privilege so $3 on my last piece of code will be equal to SeServiceLogonRight: code: I'll try to write this up for you as soon as I get some time. CF |
||
|
|
|
RobGrant Senior Member
Registered: Sep 2004 |
Yeah, I'm seeing what you're saying, although I don't think I can yet translate that into what I need for myself. I tried seeing what was in r1, r2 and r3, I think r3 was "1" when the privilege was enabled, and "0" otherwise...don't know if that helps. __________________ |
||
|
|
|
CancerFace Senior Member
Registered: Apr 2006 |
code: Apparently I was not the only one who thought that we could get the data out using an LSA_UNICODE_STRING array as I suggested ![]() However, I failed to translate the above code to a working NSIS system call. This is where the real pros have to jump into this discussion ... CF |
||
|
|
|
RobGrant Senior Member
Registered: Sep 2004 |
Ah mate, thanks for all your help. Hopefully someone even more experienced than you can help __________________ |
||
|
|
|
kichik M.I.A. [NSIS Dev, Mod]
Registered: Oct 2001 |
CancerFace, that page is talking about C#, not C. A few problems: Maybe I inherit all of my privileges from the groups that contain my user.code: __________________ |
||
|
|
|
RobGrant Senior Member
Registered: Sep 2004 |
Is it possible to pull all of that into one script? __________________ |
||
|
|
|
CancerFace Senior Member
Registered: Apr 2006 |
I knew there was something I forgot to post here code: Note that if your user has no extra rights then the LsaEnumerateAccountRights gives a wierd error on $R8 which you can convert to a windows error using and in that case $R9 is equal to 2 (check what kitchik was talking about a few posts up)code: The rights will have the format that I posted before (for example SeInteractiveLogonRight) The above works for me ![]() CF |
||
|
|
|
RobGrant Senior Member
Registered: Sep 2004 |
Perfect! Thank you so much guys, that's it exactly! __________________ |
||
|
|
|
CancerFace Senior Member
Registered: Apr 2006 |
Added a WIKI page for this thread |
||
|
|
|
Last Thread Next Thread
|
WINAMP.COM | Forums > Developer Center > NSIS Discussion > Check a user has a certain permission |
Forum Rules:
|