Token of user identity

  • Thread starter Thread starter ptran123
  • Start date Start date
P

ptran123

In IIS, when 'anonymous user' is disabled anyone entering the site must
be authenticated. After authentication, IIS's worker process assumes
the identity of the authenticated user rather than the identity of the
worker process. So far I've only found code that obtains the token of
the worker process' identity. That's not what I need. Is there a way
to obtain the token for the user? Thanks in advance.
 
Hi,

Since you deny anonymous access, you can get authenticated
user by

User.Identity.Name

It gives you DomainName\userID.

HTH

Elton Wang
(e-mail address removed)
 
Hi ptran:

Do you have <authentication mode='Windows'/> and <deny users='?'/>
in your web.config? You should be able to cast Page.User.Identity to a
WindowsIdentity, which represents a token.

--s
 
Actually, what I really need is the TokenPtr of the authenticated
user. That way I can get the SID of that user, and store it in the DB.
I only know how to get the tokenPtr of the process identity by the
code below.

WindowsIdentity wi = WindowsIdentity.GetCurrent();
IntPtr token = wi.Token;

the variable 'token' holds a pointer to the process identity. However I
need the tokenPtr of the authenticated user. ASP.NET doesn't seem to
have this capability.
 
Back
Top