• JimS-Indy (10/9/2012)


    Yeah, so I'm getting the impression the ASP.NET app must accept all comers, authenticate them, then use the Network Service to access the db. I can live with that. If I'm in an AD environment, can I authenticate from the ASP.NET app without asking the user to log in again?

    No, it doesn't have to use Network Service or a fixed account to access the db.

    Here is a very simple sample web.config and default.aspx that shows how simple it can be to use Windows Auth in ASP.NET to connect.

    Web.config

    <?xml version="1.0"?>

    <configuration>

    <connectionStrings>

    <add name="DemoConnectionString" connectionString="Data Source=MyServer;Initial Catalog=master;Integrated Security=True"

    providerName="System.Data.SqlClient" />

    </connectionStrings>

    <system.web>

    <compilation debug="true" targetFramework="4.0" />

    <authentication mode="Windows">

    </authentication>

    </system.web>

    </configuration>

    And the web page:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WinAuthToSQLDemo.Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">

    <title></title>

    </head>

    <body>

    <form id="form1" runat="server">

    <div>

    <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px"

    AutoGenerateRows="False" DataSourceID="SqlDataSource1">

    <Fields>

    <asp:BoundField DataField="ConnectedUser" HeaderText="Connected User"

    ReadOnly="True" SortExpression="ConnectedUser" />

    </Fields>

    </asp:DetailsView>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server"

    ConnectionString="<%$ ConnectionStrings:DemoConnectionString %>"

    SelectCommand="SELECT SUSER_SNAME() AS ConnectedUser"></asp:SqlDataSource>

    </div>

    </form>

    </body>

    </html>

    You will see that it couldn't really be any simpler - this simple web page will connect to your SQL server and return the name of the user.

    Obviously, you must ensure the web site has only ASP.NET Impersonation and Windows Authentication enabled in the "Authentication" settings for this to work...

    Edit: fix wording in last sentence.

    MM



    select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);

  • Forum Etiquette: How to post Reporting Services problems
  • [/url]
  • Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
  • [/url]
  • How to Post Performance Problems - by Gail Shaw
  • [/url]