Generating a Windown generated username/password dialog box

Posted on 2005-04-04
Medium Priority
Last Modified: 2010-04-07
Is their a way to create a Windows generated username / password dialog box in asp .net?

This is how I have it in regualr asp....

Dim userId

userID = Request.ServerVariables("LOGON_USER")

If (userID = "") Then
   Response.Status = "401 access denied"
   Response.Write("<B>You do not have access to this page.</B>")
%><!-- Comment out redirection code
<meta http-equiv="REFRESH" content="0; URL=default.asp"> </head> <body bgcolor="white"> </body> </html>

End If
<body >
The userID is <%= userID%>

......but when I try this in .net, sessionvariables("logon_user") is blank
Question by:shuittny
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 23

Accepted Solution

b1xml2 earned 2000 total points
ID: 13699388
IIS Settings
1. Open the Internet Information Services under Adminstrative Tools
2. Select The WebApplication and select "Properties"
3. Select the "Directory Security" Tab
4. Click on the Edit button inside the "Anonymous access and authentication control"
5. De-select "Anonymous access"
6. Select "Integrated Windows Authentication"
7. Click OK

.NET Settings
1. Open web.config file
2. Ensure the following:

<authentication mode="Windows" />

under this, add the following:

<identity impersonate="true" />
3. Inside ASP.NET, to access the User,

Author Comment

ID: 13699519
keep the original code the same on top of all of that
LVL 23

Expert Comment

ID: 13699532
ASP is not the same as ASP.NET. <EOM>
LVL 23

Expert Comment

ID: 13699692
<%@ Page Language="vb" %>
<script language="vb" runat="server">
Sub Page_Load(ByVal sender As Object,ByVal e As EventArgs)
LiteralUserName.Text = User.Identity.Name
If Not User.IsInRole(@"<server>\<group>") Then
      Response.StatusCode = 401
      Response.StatusDescription = "401 Access Denied"
End If
End Sub
The userId Is <asp:Literal Id="LiteralUserName" runat="server" />

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question