Results 1 to 7 of 7

Thread: [RESOLVED] [2.0] [2005] Vista, check to see what I am running as

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    5

    Resolved [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

  2. #2
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    5

    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.

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    5

    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!

  5. #5
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    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.

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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.

  7. #7
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width