Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
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.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Login failed for user. Protoman Classic ASP Databases 3 January 13th, 2008 12:23 PM
Funky - Login Failed for user 'Domain\UserId' erro jnks2005 ASP.NET 2.0 Basics 5 February 26th, 2007 12: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



All times are GMT -4. The time now is 05:11 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.