Registration request when using Integrated Windows authentication

For an ASP.NET application, how can I prompt the user for their username / password when Integrated Windows Authentication is used? I would like to use C # in the code behind the pages for this.

I need multiple pages (e.g. http: // intranet / admin / ) to ask for a password, while others go automatically (via IWA / NTLM), I would like it to remember that the user is logged in when they visit other pages in the folder / site and offer a logout link when completed.

Edit: What I want to do is send the user a 401 status and WWW authentication headers so that they can then log in using their Windows credentials.

Basically how Firefox / IE does it if the site is not trusted.

Edit 2: SharePoint does things like this where you automatically log in, but you can log out and log in as someone else without requiring you to log out of Windows.

Edit 3:

Example (non-SharePoint): You are logged in as a normal (restricted) Windows / Active Directory user to a trusted site that transfers your credentials. Then you want to login to the admin area of ​​the site with different credentials (but still Windows, not WebForms). The only way to do this is to log out of Windows and then log back in. It is impractical if you have files open (which you might want to access) or the administrator cannot log in locally (interactive logon is disabled). Impersonation can be set because the page allows access to applications that are not normally associated with a regular user account (for example, databases, files, Active Directory administrator).

Basically, creating a page on a site behaves as if it is not part of the Trusted Sites zone.

+2


source to share


2 answers


It looks like you need to use impersonation. This allows you to run as "another Windows user". See here: ASP.NET Impersonation

Here are some CodeProject examples:



Impersonating Windows using C #

.NET custom impersonation

+1


source


There is no separate code for this.

When a user / client opens a specific page like http: //intranet/admin/index.aspx

if you configure a specific folder using windows authentication, the browser will



automatically prompts for the username and password of a specific user / client.

so this is the configuration you have to do in IIS for a specific folder

to which you would like to apply Integrated Windows Authentication.

-1


source







All Articles