[RESOLVED] Retrievingn Authenticated User Parameters
in an asp.net application, what is the difference between Threading.Thread.CurrentPrincipal.Identity.Name and Page.User.Identity.Name?
Re: Retrievingn Authenticated User Parameters
Hey,
In theory, the first should give you the identity of the user that is running the currently executing thread, which when running under IIS, may well be the identity of the configured Application Pool, and the second should give you the name of the currently authenticated user to your site.
Now again, in theory, depending on how your web site is set up (for example, using impersonation), these two parameters could return the exact same user.
Gary
Re: Retrievingn Authenticated User Parameters
Quote:
Originally Posted by
gep13
Hey,
In theory, the first should give you the identity of the user that is running the currently executing thread, which when running under IIS, may well be the identity of the configured Application Pool, and the second should give you the name of the currently authenticated user to your site.
Now again, in theory, depending on how your web site is set up (for example, using impersonation), these two parameters could return the exact same user.
Gary
thanks,
but 1 more thing, when using a class library (DLL) in an asp.net application, how best should i refer to the Page.User.Identity.Name irrespective of how ISS is setup?
Re: Retrievingn Authenticated User Parameters
Page.User.Identity.Name should always give you the name of the Authenticated User to your site. What authentication scheme are you using for your site? Are you trying to take an action within your DLL based on the current user?
Gary
Re: Retrievingn Authenticated User Parameters
Quote:
Originally Posted by
gep13
Page.User.Identity.Name should always give you the name of the Authenticated User to your site. What authentication scheme are you using for your site? Are you trying to take an action within your DLL based on the current user?
Gary
exactly, am trying to retrieve the current authenticated user from a DLL. I am currently using Forms Authentication
Re: Retrievingn Authenticated User Parameters
From the DLL?!?
That doesn't really make sense. You should, in theory, be passing the name of the authenticated user from your UI, to the DLL.
Can you show some of the code that you are using? With information about what username you are actually getting, and what you are expecting?
Gary
Re: Retrievingn Authenticated User Parameters
Quote:
Originally Posted by
gep13
From the DLL?!?
That doesn't really make sense. You should, in theory, be passing the name of the authenticated user from your UI, to the DLL.
Can you show some of the code that you are using? With information about what username you are actually getting, and what you are expecting?
Gary
ok, good one. Its just that i have lots of entry points (functions & subs ) in the DLL and am currently passing Page.User.Identity.Name as part of the parameters from the UI to the DLL. I was thinking, if Page.User.Identity.Name=Threading.Thread.CurrentPrincipal.Identity.Name ,then i could drop this parameter & fetch the required value directly from DLL. I was trying to reduce the parameter list:wave:
Re: Retrievingn Authenticated User Parameters
Ah, I see what you mean.
I would say that this would be a bad design decision, rather, leave the UserName coming from the UI? How many parameters are we talking about? Can you create a class with properties on it, and pass that as a parameter to the method/sub?
Gary
Re: Retrievingn Authenticated User Parameters
Quote:
Originally Posted by
gep13
Ah, I see what you mean.
I would say that this would be a bad design decision, rather, leave the UserName coming from the UI? How many parameters are we talking about? Can you create a class with properties on it, and pass that as a parameter to the method/sub?
Gary
ok, thanx man!:wave:
Re: [RESOLVED] Retrievingn Authenticated User Parameters
Not a problem at all.
Gary