Results 1 to 10 of 10

Thread: [RESOLVED] Retrievingn Authenticated User Parameters

  1. #1

    Thread Starter
    Hyperactive Member oyad's Avatar
    Join Date
    Feb 2003
    Location
    PhoxWare MicroSystems
    Posts
    463

    Resolved [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?
    Nobody is smarter than all of us!

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  3. #3

    Thread Starter
    Hyperactive Member oyad's Avatar
    Join Date
    Feb 2003
    Location
    PhoxWare MicroSystems
    Posts
    463

    Re: Retrievingn Authenticated User Parameters

    Quote Originally Posted by gep13 View Post
    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?
    Nobody is smarter than all of us!

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  5. #5

    Thread Starter
    Hyperactive Member oyad's Avatar
    Join Date
    Feb 2003
    Location
    PhoxWare MicroSystems
    Posts
    463

    Re: Retrievingn Authenticated User Parameters

    Quote Originally Posted by gep13 View Post
    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
    Nobody is smarter than all of us!

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  7. #7

    Thread Starter
    Hyperactive Member oyad's Avatar
    Join Date
    Feb 2003
    Location
    PhoxWare MicroSystems
    Posts
    463

    Re: Retrievingn Authenticated User Parameters

    Quote Originally Posted by gep13 View Post
    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
    Nobody is smarter than all of us!

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  9. #9

    Thread Starter
    Hyperactive Member oyad's Avatar
    Join Date
    Feb 2003
    Location
    PhoxWare MicroSystems
    Posts
    463

    Re: Retrievingn Authenticated User Parameters

    Quote Originally Posted by gep13 View Post
    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!
    Nobody is smarter than all of us!

  10. #10
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] Retrievingn Authenticated User Parameters

    Not a problem at all.

    Gary

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