Re: Authorizing users based on User Groups

From: Joe Kaplan \(MVP - ADSI\) (joseph.e.kaplan_at_removethis.accenture.com)
Date: 08/27/03


Date: Wed, 27 Aug 2003 12:16:48 -0500


It still can. In a Win32 application, you get the current principal by
calling System.Threading.Thread.CurrentPrincipal. This can return to you a
WindowsPrincipal that will contain the token and groups of the current
logged on user.

However, you need to do a little bit more work to get this to work because
by default Windows apps don't set the IPrincipal on each thread. To get
that to happen, you need to set the PrincipalPolicy on the current AppDomain
to PrincipalPolicy.WindowsPrincipal. You should be able to do that with:

AppDomain.Current.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal)

However, you need the appropriate CAS SecurityPermission (with
ControlPrincipal flag) to set the AppDomain's PrincipalPolicy (see the docs
for more details). Generally you will have this if the app is installed
locally (you will have FullTrust), but if it is run from a network share or
downloaded, you may not by default.

HTH,

Joe K.

"Edwin" <Edwin.Loubser@comau.co.za> wrote in message
news:07df01c36c74$3bc5f0e0$a601280a@phx.gbl...
> Ok but this is a normal Windows 32 application, the user
> is not authenticated via IIS. Will this information still
> be available?
>
> Thanx



Relevant Pages

  • Re: How To let all users in a Group to call a method by using an attribute?
    ... GenericPrincipal instance, which has no knowledge of the current ... If you want the windows principal to be used across the app domain, ... WindowsPrincipal value from the PrincipalPolicy enumeration: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Why questions dont get answered, or "No, Ive already RTFM, tell me the answer!"
    ... >> having your first experience by installing windows and about ... I'd hate to know I had to spend that much time installing Windows ... bundled with win95 and a bunch of windows apps. ... didn't pay someone to build and test your hardware with exactly ...
    (Fedora)
  • Re: Safari shall win the browser wars
    ... This is more of a problem for Windows apps on the Mac than Mac apps ... "That's George Washington, the first president, of course. ...
    (comp.sys.mac.advocacy)
  • Re: Look mom I can do C#
    ... white theme. ... has an option to use the proper user's Windows colour scheme rather ... many Windows apps at least) haven't traditionally done it too well. ...
    (microsoft.public.vc.mfc)
  • Re: Mac run Windows now.
    ... apps why would you switch to OSX? ... Speaking as one long time Windows user with a HUGE ... investment over the years in Windows apps, ... OSX, at least for some of my audio editing - all if I can find ...
    (rec.audio.pro)