[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
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 ;)
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.
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!
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.
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.
Re: [RESOLVED] [2.0] [2005] Vista, check to see what I am running as
Quote:
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)