Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
| Search | Today's Posts | Mark Forums Read
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 29th, 2009, 10:45 AM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 30
Thanks: 1
Thanked 0 Times in 0 Posts
Default login failed for user Domain\User ID

My users are trying to connect to SQL Server 2005 from an Intranet application. All users are on Active Directory, if that makes a difference. Within SQL 2005 three Application Roles have been created, General, Supervisors and Administrators.

Some users are assigned to all three groups, some to two groups and others to one single group. Only those users assigned to all three groups are able to view the web page, all others get the following error:

System.Data.SqlClient.SqlException: Login failed for user 'DOMAIN\USERID'

My web.config file connection string:

<add name="ConnectString" connectionString="Data Source=DataSource;Initial Catalog=Dance;User ID=AOwner;Integrated Security=SSPI;Trusted_Connection=True;Pooling=Fals e"
providerName="System.Data.SqlClient"/>

My code behind file:

Partial Class Login_Default
Inherits System.Web.UI.Page
'Establish connection to the database connection
Dim sqlcon As New SqlClient.SqlConnection(ConfigurationManager.Conne ctionStrings("DancerConnectionString").ToString)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Session("ID") = txtEmpID.Text
Session("WINNT") = Replace(HttpContext.Current.User.Identity.Name.ToS tring, "DOMAIN\", "")
txtEmpID.Focus()
Dim cmd As New SqlClient.SqlCommand
cmd.Connection = sqlcon
cmd.CommandText = "sp_setapprole"
cmd.CommandType = CommandType.StoredProcedure
Dim rolename As SqlClient.SqlParameter = cmd.Parameters.Add("@rolename", SqlDbType.VarChar, 20)
rolename.Value = "GeneralUser"
Dim password As SqlClient.SqlParameter = cmd.Parameters.Add("@password", SqlDbType.VarChar, 20)
password.Value = "GeneralUserPassword"
sqlcon.Open()
cmd.ExecuteNonQuery()
Dim strUser As String
strUser = "DOMAIN\(AREA) SQL GENERAL Users"
If (Roles.IsUserInRole(strUser)) Then
txtEmpID.Focus()
Else
Response.Redirect("http://AREA/home.asp")
End If
sqlcon.Close()
cmd.Dispose()
End Sub

End Sub
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim cmdRtnValue As SqlCommand = New SqlCommand
cmdRtnValue.CommandType = CommandType.StoredProcedure
cmdRtnValue.CommandText = "usp_GetID"
cmdRtnValue.Parameters.AddWithValue("@ID", Session("ID"))
cmdRtnValue.Parameters.AddWithValue("@WINNT", Session("WINNT"))
cmdRtnValue.Connection = sqlcon
sqlcon.Open()
cmdRtnValue.ExecuteScalar()
lblEmpName.Text = cmdRtnValue.ExecuteScalar().ToString()
If (lblEmpName.Text) = "0" Then
If txtEmpID.Text = "" Then
lblEmpName.Text = "You must enter your Employee ID number."
Else
lblEmpName.Text = "Invalid Employee ID number entered: " & txtEmpID.Text & "; please try again"
End If
Else
Session("Tracking") = "1"
Response.Redirect("LoginType.aspx")
End If
cmdRtnValue.Dispose()
cmdRtnValue.Connection.Close()

End Sub

Thank you.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Login failed for user. Protoman Classic ASP Databases 3 January 13th, 2008 01:23 PM
Funky - Login Failed for user 'Domain\UserId' erro jnks2005 ASP.NET 2.0 Basics 5 February 26th, 2007 01:38 PM
login failed for user domain\user babakwx SQL Server 2000 2 May 30th, 2006 12:28 PM
login failed for user nt authority\anonymous login rj1406 Classic ASP Databases 1 October 24th, 2004 09:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.