Remote server

  • Hi,i have all my files .aspx files in server(A).My IIS is in Server(A).My database is in server(B).How can i get conntected from server(A)to server(B) through windows authentication.if its SQL authentication then theres no issues but if i get conntected with windows authentication it give me a error "No trusted conntection"

    regards

    hemant

  • ASP.NET process is running in certain user/system account context (in W2k3 it will be NETWORK SERVICE account, in W2k and XP it going to be ASPNET user).

    See more about it:

    http://msdn.microsoft.com/library/en-us/dnnetsec/html/SecNetch08.asp?frame=true#secnetch08_processidforaspnet

    To access SQL Server resources from ASP.NET application you have to authenticate account that your ASP.NET process context is on SQL Server.

    You can use Windows Domain account and make ASP.NET process running in context of this account, and set permissions for this account to access SQL Server.

    You can also duplicate ASP.NET account on SQL Server machine and set permissions for this duplicated account access SQL Server.

    Few links that might be useful:

    ASP.NET to SQL Server

    http://msdn.microsoft.com/library/en-us/dnnetsec/html/SecNetch05.asp?frame=true#secnetch05_aspnettosql

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT01.asp

    Regards

    Max Mulawa

  • Hi Hemant,

    The easiest thing to do would be:

    1) Go to Server B.

    2) Go to Security--Logins.

    3) Right click on the Logins node and create a New Login.

    4) Click on the ellipse button beside the Name textbox and select your login name from your desired domain. (Make sure Windows Authentication is selected and the Security access is selected to Grant access).

    5) Select the default database of your choice and click OK.

    6) Open the desired database tree and go to the Users node.

    7) Right click on the Users node and create a New Database User and choose your name in the Login name dropdown. Make sure the Database role membership "public" is checked.

    8) Go to Server A.

    9) In your web.config file:

    <?

    xml version="1.0" encoding="utf-8"?>

    <

    configuration>

    <

    system.web>

    ...

    ...

    </system.web>

    <appSettings>

    <add key="sqlConnection.ConnectionString" value="data source=ServerB;packet size=8192;pooling=true;integrated security=SSPI;persist security info=False;initial catalog=databasename;connection timeout=3;Min Pool Size=100;Max Pool Size=1000" />

    </appSettings>

    </

    configuration>

     

    In your code create a private class variable:

    (C#)

    private

    string connectionString = ((string)((new System.Configuration.AppSettingsReader()).GetValue("sqlConnection.ConnectionString", typeof(string))));

    Then use this variable in ADO.NET as:

    SqlConnection sqlConnection = new SqlConnection();

    sqlConnection.ConnectionString = connectionString;

     

    Hope this helps.

    Tony John.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply