Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Login failed. The login is from an untrusted domain and cannot be used with Windows authentication

Tags:

People also ask

How do I turn off Windows authentication in SQL?

In Object Explorer, open Security folder, open Logins folder. Right click on the local account and go to Properties. In the Login Properties window, select the Status tab. Set Login to Disabled, or set Permission to connect to database engine to Deny.

How do I enable integrated security in SQL Server?

To implement SQL Server integrated security, perform the following steps: From SQL Enterprise Manager, right-click the SQL Server name that appears in the Server Manager window and click Configure on the shortcut menu. Click Security Options. Select Windows NT Integrated as the Login Security Mode, and then click OK.

What is Integrated Security False?

Integrated Security When false, User ID and Password are specified in the connection. When true, the current Windows account credentials are used for authentication. Recognized values are true, false, yes, no, and sspi (strongly recommended), which is equivalent to true.


My webpages are on secured server (https), and I am trying to connect the SQL Server 2008 Database, which is normal server. I am writing connectionstring on page itself, not in web.config file. And I am getting following error:-

System.Data.SqlClient.SqlException: Login failed.
The login is from an untrusted domain and cannot be used with Windows authentication.

Please help, how can I connect it, does I have to make some webservices for it.

my code is as below:

public void FillCity()
{
    SqlConnection con = new SqlConnection();
    con.ConnectionString = "integrated security=SSPI;data source=dev-fcb; user id=sa;password=password;" 
    +"persist security info=False;database=mediapro";
    con.Open();
    SqlDataAdapter da = new SqlDataAdapter();
    da.SelectCommand = new SqlCommand("select * from StateCityMaster where IsActive='1' order by CityName", con);
    DataSet ds = new DataSet();
    da.Fill(ds);
    string CityName = string.Empty;
    if (ds.Tables[0].Rows.Count > 0)
    {
        CityName = ds.Tables[0].Rows[0]["CityName"].ToString();
    }
    DataSet dset = new DataSet();
    da.Fill(dset);
    if (dset.Tables[0].Rows.Count > 0)
    {
        drpCity.DataSource = dset;
        drpCity.DataTextField = "CityName";
        drpCity.DataValueField = "CityName";
        drpCity.DataBind();
    }
    drpCity.Items.Insert(0, new ListItem("--Select--", "0"));
    con.Close();
}