p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > SQL Server > SQL Server 2005 > SQL Server 2005
I forgot my password Register Now
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 29th, 2009, 11:45 AM
Authorized User
Points: 140, Level: 2
Points: 140, Level: 2 Points: 140, Level: 2 Points: 140, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 01:28 PM
login failed for user NT AUTHORITY\ANONYMOUS LOGIN rj1406 ASP.NET 1.1 1 October 24th, 2004 03:05 PM
login failed for user nt authority\anonymous login rj1406 Classic ASP Databases 1 October 24th, 2004 10:15 AM



All times are GMT -4. The time now is 09:30 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc