Connecting Tech Pros Worldwide Forums | Help | Site Map

threading and Principal question - from Role-based security to declarative security.

hazz
Guest
 
Posts: n/a
#1: Nov 16 '05
If I successfully run a VS.NET app which includes the following;

************************** APP 1 ****************************

m_iIdnt = new
System.Security.Principal.GenericIdentity(t.UserNa me,"MyAuthentication");
//user and My authentication type added to Identity

string[] roles = {"Chief Cook and Bottle Washer", "Master Gardener"};


m_iPrincipal = new
System.Security.Principal.GenericPrincipal(m_iIdnt ,roles); //roles and
Identity added to Principal

System.Threading.Thread.CurrentPrincipal = m_iPrincipal; //Threads
current principal is set

************************************************** **************

and then create a new VS.NET app to retrieve the Principal and Identity off
the thread created in APP 1 above


*************************** APP 2 ****************************


AppDomain.CurrentDomain.SetPrincipalPolicy(Princip alPolicy.WindowsPrincipal)
;
IPrincipal currentPrincipal = Thread.CurrentPrincipal;


IIdentity currentIdentity = currentPrincipal.Identity;
string authtype = currentIdentity.AuthenticationType;
string iden = currentIdentity.Name;

************************************************** **************

I get NTLM as the authentication type.
I want to retrieve the thread that has "MyAuthentication" as the
authenticationtype.

Where am I at in the landscape here? Different app domains, different
threads, different principle?

Where I am trying to go is move from a role-based initiation of user/role
and then later using declarative security, grab the user/role from the
"appropriate runtime thread" (where my understanding falls apart) to compare
with a database or config file user/role.

Thank you for helping me with the context and any implementation details.

-Greg



hazz
Guest
 
Posts: n/a
#2: Nov 16 '05

re: threading and Principal question - from Role-based security to declarative security.


I think I just discovered the obvious? You can't cross AppDomains with the
Principal and Identity. Separate thread.
As long as the app is alive, I can use GenericPrincipal to access the Custom
AuthenticationType and custom roles only within the "context" from which the
app is created, and only on the thread associated with that application.
The app will authenticate the user, the app will assign the role for that
user and retain the roles on the thread that both belong to the app and the
user for the lifetime of the application. If the user leaves (shuts down the
app) they will have to re-authenticate.


"hazz" <hazz@sonic.net> wrote in message
news:uVS6Qr8VEHA.3024@TK2MSFTNGP09.phx.gbl...[color=blue]
> If I successfully run a VS.NET app which includes the following;
>
> ************************** APP 1 ****************************
>
> m_iIdnt = new
> System.Security.Principal.GenericIdentity(t.UserNa me,"MyAuthentication");
> //user and My authentication type added to Identity
>
> string[] roles = {"Chief Cook and Bottle Washer", "Master Gardener"};
>
>
> m_iPrincipal = new
> System.Security.Principal.GenericPrincipal(m_iIdnt ,roles); //roles and
> Identity added to Principal
>
> System.Threading.Thread.CurrentPrincipal = m_iPrincipal; //Threads
> current principal is set
>
> ************************************************** **************
>
> and then create a new VS.NET app to retrieve the Principal and Identity[/color]
off[color=blue]
> the thread created in APP 1 above
>
>
> *************************** APP 2 ****************************
>
>
>[/color]
AppDomain.CurrentDomain.SetPrincipalPolicy(Princip alPolicy.WindowsPrincipal)[color=blue]
> ;
> IPrincipal currentPrincipal = Thread.CurrentPrincipal;
>
>
> IIdentity currentIdentity = currentPrincipal.Identity;
> string authtype = currentIdentity.AuthenticationType;
> string iden = currentIdentity.Name;
>
> ************************************************** **************
>
> I get NTLM as the authentication type.
> I want to retrieve the thread that has "MyAuthentication" as the
> authenticationtype.
>
> Where am I at in the landscape here? Different app domains, different
> threads, different principle?
>
> Where I am trying to go is move from a role-based initiation of user/role
> and then later using declarative security, grab the user/role from the
> "appropriate runtime thread" (where my understanding falls apart) to[/color]
compare[color=blue]
> with a database or config file user/role.
>
> Thank you for helping me with the context and any implementation details.
>
> -Greg
>
>[/color]


Scott Allen
Guest
 
Posts: n/a
#3: Nov 16 '05

re: threading and Principal question - from Role-based security to declarative security.


Check out:
A .net developer's guide to Windows security by Keith Brown.
http://www.pluralsight.com/keith/book/

HTH,

--
Scott
http://www.OdeToCode.com

On Mon, 21 Jun 2004 15:27:14 -0600, "hazz" <hazz@sonic.net> wrote:
[color=blue]
>I think I just discovered the obvious? You can't cross AppDomains with the
>Principal and Identity. Separate thread.
>As long as the app is alive, I can use GenericPrincipal to access the Custom
>AuthenticationType and custom roles only within the "context" from which the
>app is created, and only on the thread associated with that application.
>The app will authenticate the user, the app will assign the role for that
>user and retain the roles on the thread that both belong to the app and the
>user for the lifetime of the application. If the user leaves (shuts down the
>app) they will have to re-authenticate.
>
>[/color]

hazz
Guest
 
Posts: n/a
#4: Nov 16 '05

re: threading and Principal question - from Role-based security to declarative security.


Thank you Scott!
Much appreciated....
-Greg

"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:j3dgd05v7520hr0qremdfsaj3ho9kfjej2@4ax.com...[color=blue]
> Check out:
> A .net developer's guide to Windows security by Keith Brown.
> http://www.pluralsight.com/keith/book/
>
> HTH,
>
> --
> Scott
> http://www.OdeToCode.com
>
> On Mon, 21 Jun 2004 15:27:14 -0600, "hazz" <hazz@sonic.net> wrote:
>[color=green]
> >I think I just discovered the obvious? You can't cross AppDomains with[/color][/color]
the[color=blue][color=green]
> >Principal and Identity. Separate thread.
> >As long as the app is alive, I can use GenericPrincipal to access the[/color][/color]
Custom[color=blue][color=green]
> >AuthenticationType and custom roles only within the "context" from which[/color][/color]
the[color=blue][color=green]
> >app is created, and only on the thread associated with that application.
> >The app will authenticate the user, the app will assign the role for that
> >user and retain the roles on the thread that both belong to the app and[/color][/color]
the[color=blue][color=green]
> >user for the lifetime of the application. If the user leaves (shuts down[/color][/color]
the[color=blue][color=green]
> >app) they will have to re-authenticate.
> >
> >[/color]
>[/color]


hazz
Guest
 
Posts: n/a
#5: Nov 16 '05

re: threading and Principal question - from Role-based security to declarative security.


The following comes from
http://msdn.microsoft.com/library/de...html/DAMAZ.asp

Using Automatic Identity Flow
The common language runtime automatically provides identity flow when all of
the code that requires the identity executes in the same context. The caller
and callee are in the same context when they share the same application
domain. If the client code (referred to as the caller) and the component
being called (referred to as the callee) are running within the same
context, .NET automatically uses the same Thread.CurrentPrincipal object for
both the caller and the callee. For cases in which the callee and caller
execute on different threads, see "Performing Authorization with Multiple
Threads" later in this chapter.

"hazz" <hazz@sonic.net> wrote in message
news:ejiIHa9VEHA.808@tk2msftngp13.phx.gbl...[color=blue]
> I think I just discovered the obvious? You can't cross AppDomains with the
> Principal and Identity. Separate thread.
> As long as the app is alive, I can use GenericPrincipal to access the[/color]
Custom[color=blue]
> AuthenticationType and custom roles only within the "context" from which[/color]
the[color=blue]
> app is created, and only on the thread associated with that application.
> The app will authenticate the user, the app will assign the role for that
> user and retain the roles on the thread that both belong to the app and[/color]
the[color=blue]
> user for the lifetime of the application. If the user leaves (shuts down[/color]
the[color=blue]
> app) they will have to re-authenticate.
>
>
> "hazz" <hazz@sonic.net> wrote in message
> news:uVS6Qr8VEHA.3024@TK2MSFTNGP09.phx.gbl...[color=green]
> > If I successfully run a VS.NET app which includes the following;
> >
> > ************************** APP 1 ****************************
> >
> > m_iIdnt = new
> >[/color][/color]
System.Security.Principal.GenericIdentity(t.UserNa me,"MyAuthentication");[color=blue][color=green]
> > //user and My authentication type added to Identity
> >
> > string[] roles = {"Chief Cook and Bottle Washer", "Master Gardener"};
> >
> >
> > m_iPrincipal = new
> > System.Security.Principal.GenericPrincipal(m_iIdnt ,roles); //roles and
> > Identity added to Principal
> >
> > System.Threading.Thread.CurrentPrincipal = m_iPrincipal; //Threads
> > current principal is set
> >
> > ************************************************** **************
> >
> > and then create a new VS.NET app to retrieve the Principal and Identity[/color]
> off[color=green]
> > the thread created in APP 1 above
> >
> >
> > *************************** APP 2 ****************************
> >
> >
> >[/color]
>[/color]
AppDomain.CurrentDomain.SetPrincipalPolicy(Princip alPolicy.WindowsPrincipal)[color=blue][color=green]
> > ;
> > IPrincipal currentPrincipal = Thread.CurrentPrincipal;
> >
> >
> > IIdentity currentIdentity = currentPrincipal.Identity;
> > string authtype = currentIdentity.AuthenticationType;
> > string iden = currentIdentity.Name;
> >
> > ************************************************** **************
> >
> > I get NTLM as the authentication type.
> > I want to retrieve the thread that has "MyAuthentication" as the
> > authenticationtype.
> >
> > Where am I at in the landscape here? Different app domains, different
> > threads, different principle?
> >
> > Where I am trying to go is move from a role-based initiation of[/color][/color]
user/role[color=blue][color=green]
> > and then later using declarative security, grab the user/role from the
> > "appropriate runtime thread" (where my understanding falls apart) to[/color]
> compare[color=green]
> > with a database or config file user/role.
> >
> > Thank you for helping me with the context and any implementation[/color][/color]
details.[color=blue][color=green]
> >
> > -Greg
> >
> >[/color]
>
>[/color]


Closed Thread