|
-
Sep 12th, 2007, 02:59 PM
#1
Thread Starter
New Member
[RESOLVED] [2.0] [2005] Vista, check to see what I am running as
Hello all,
I'm writing a program for Vista and I'd like to check if I am running as administrator or with administrative privileges. Is there a quick and painless way to do this?
Thank you kindly for any ideas/assistance you can provide.
Patrick
-
Sep 13th, 2007, 01:44 AM
#2
Re: [2.0] [2005] Vista, check to see what I am running as
You can use....
Code:
System.Security.Principal.WindowsIdentity.GetCurrent().IsGuest.ToString();
To check if the account is a guest. Which if it returns false then it means it should be good to go
-
Sep 13th, 2007, 09:20 AM
#3
Thread Starter
New Member
Re: [2.0] [2005] Vista, check to see what I am running as
I checked the suggestion out you posted.
Sadly, whether I check within an administrator account, do "run as administrator" on a normal account or just run normally under a normal account, IsGuest always returns false.
I did some poking around and IsAuthenticated, IsSystem, ImpersonationLevel, etc. all return the same values (true, false and none respectively) for all 3 cases so I cannot do any differentiation there.
I fooled around with SID comparison (GetCurrent().User.IsWellKnown(System.Security.Principal.WellKnownSidType.*) but I have not had any luck so far.
If anyone has any other suggestions, I'd love to hear it.
-
Sep 13th, 2007, 09:34 AM
#4
Thread Starter
New Member
Re: [2.0] [2005] Vista, check to see what I am running as
I could've sworn I replied to this post. At any rate, IsGuest gave the same result whether I was administrator, ran the program as administrator or used a normal account.
However, the following is true if administrator or running as administrator and false if a normal account:
System.Security.Principal.WindowsIdentity.GetCurrent().Owner.IsWellKnown(System.Security.Principal.W ellKnownSidType.BuiltinAdministratorsSid);
Thank you for the suggestion, it definitely pointed me in the right direction!
-
Sep 13th, 2007, 07:14 PM
#5
Re: [2.0] [2005] Vista, check to see what I am running as
Thats cool, always glad to help 
Now thats its resolved Could you please resolve the thread by clicking Thread Tools then Mark Thread Resolved.
-
Sep 14th, 2007, 09:32 AM
#6
Re: [RESOLVED] [2.0] [2005] Vista, check to see what I am running as
You may also wish to research the Vista-specific API functions that let you request a temporary permissions elevation from a non-administrator account.
-
Sep 14th, 2007, 06:33 PM
#7
Re: [RESOLVED] [2.0] [2005] Vista, check to see what I am running as
 Originally Posted by penagate
You may also wish to research the Vista-specific API functions that let you request a temporary permissions elevation from a non-administrator account.
I think this is it, Windows Vista (Windows)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|