tag:blogger.com,1999:blog-6082652835152798567.post9073354334772785827..comments2024-03-28T21:41:58.974-07:00Comments on Sql server, .net and c# video tutorial: Forms authentication against users in database table - Part 92Unknownnoreply@blogger.comBlogger9125tag:blogger.com,1999:blog-6082652835152798567.post-43024809454415921392019-06-30T22:55:36.422-07:002019-06-30T22:55:36.422-07:00Here is the procedure code
/* alter procedure to ...Here is the procedure code <br />/* alter procedure to be used in lesson 92*/<br />/* alter procedure to be used in lesson 92*/<br />Alter Procedure spAuthenticateUser<br />@UserName nvarchar(100) ,<br />@Password nvarchar(100)<br />as<br />Begin<br /> Declare @Account bit<br /> Declare @Count int<br /> Declare @RetryCount int<br /> Declare @AccountLocked bit<br /> <br /> Select @AccountLocked = IsLocked<br /> from tblUsers <br /> where [UserName] = @UserName<br /><br /> -- if the account is already locked<br /> if (@AccountLocked = 1)<br /> Begin<br /> Select 1 as AccountLocked, 0 as Authenticated , 0 as RetryAttempts<br /> End<br /> else<br /> Begin<br /> -- check if the user and password match<br /> Select @Count = COUNT(UserName) <br /> from tblUsers<br /> where [UserName] = @UserName and [Password] = @Password<br /> if(@Count = 1)<br /> Begin<br /> -- reset RetryAttempts<br /> Update tblUsers<br /> Set IsLocked = Null, LockedDateTime = null, RetryAttempts = null<br /> Where [UserName] = @UserName<br /> Select 0 as AccountLocked, 1 as Authenticated , 0 as RetryAttempts<br /> End<br /> else<br /> -- Match not found<br /> Select @RetryCount = IsNull(RetryAttempts,0)<br /> from tblUsers<br /> where [UserName] = @UserName <br /> <br /> Set @RetryCount = @RetryCount +1<br /> if (@RetryCount <= 3)<br /> Begin<br /> -- if retry attempts not completed<br /> Update tblUsers<br /> Set RetryAttempts = @RetryCount<br /> Where [UserName] = @UserName<br /> Select 0 as AccountLocked, 0 as Authenticated , 0 as RetryAttempts<br /> End<br /> else<br /> Begin<br /> -- if retry attempts are completed<br /> Update tblUsers<br /> Set RetryAttempts = @RetryCount ,<br /> IsLocked = 1, <br /> LockedDateTime = GETDATE()<br /> Where [UserName] = @UserName<br /> Select 1 as AccountLocked, 0 as Authenticated , 0 as RetryAttempts<br /><br /> End<br /><br /><br /> End<br />End<br /><br />Anonymoushttps://www.blogger.com/profile/08354452625605743182noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-28738002441924618932017-06-30T07:38:52.853-07:002017-06-30T07:38:52.853-07:00Hi, I am using Form authentication with Web Form. ...Hi, I am using Form authentication with Web Form. it gives me Access is denied error on Login page when I use form authentication.ziahttps://www.blogger.com/profile/14352447603652631054noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-82550510199863467292017-06-12T02:47:20.166-07:002017-06-12T02:47:20.166-07:00When I run Your Code Its getting Error:- Object Re...When I run Your Code Its getting Error:- Object Reference not set to an instance of an object.<br /><br />On Line: 41<br />Line 39:<br />Line 40: con.Open();<br />Line 41: int returncode = (int)cmd.ExecuteScalar();<br />Line 42: if (returncode == -1)Manish Kishorehttps://www.blogger.com/profile/01101719371764093197noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-34656198736228275612014-02-24T05:33:43.957-08:002014-02-24T05:33:43.957-08:00Thankyou sir,
I want to know that how when we can ...Thankyou sir,<br />I want to know that how when we can restrict the user to access a page through url even in the same instance of the broswerAnonymoushttps://www.blogger.com/profile/11147371115937452557noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-87452389757735162722014-01-03T13:41:09.295-08:002014-01-03T13:41:09.295-08:00thanks a bunch kudvenkat,but i think it'so bet...thanks a bunch kudvenkat,but i think it'so better to use asp.net instead of creating users on database,can you explain us ,how to use aspnet membership,it will be very intersting because you are the king of explaination in the world,thanks thanks<br />Anonymoushttps://www.blogger.com/profile/01623987878727325785noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-82597917273179296282013-10-20T04:47:13.021-07:002013-10-20T04:47:13.021-07:00I mean, in this tutorial, if the table Account has...I mean, in this tutorial, if the table Account has 3 fields (Username, password, role), then the web.config authorizes user based on their "role" to access the site, how can I do that? Thanks.Peterhttps://www.blogger.com/profile/09592504183054172390noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-8720060295695809722013-10-19T08:13:43.424-07:002013-10-19T08:13:43.424-07:00Hello Sir,
Thanks for videos of authentication. Co...Hello Sir,<br />Thanks for videos of authentication. Could you give tutorial of authentication against "roles" (not users) in database. Thanks.Peterhttps://www.blogger.com/profile/09592504183054172390noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-2494074201874703162013-09-11T10:12:14.668-07:002013-09-11T10:12:14.668-07:00In the Inetmgr, -> Application Pool -> Defau...In the Inetmgr, -> Application Pool -> DefaultAppPool. Right click on this DefaultAppPool. Go to Advanced settings, change the process Model identity, to LocalSystem. It should work. Anuradha Elangovanhttps://www.blogger.com/profile/15894042746998367826noreply@blogger.comtag:blogger.com,1999:blog-6082652835152798567.post-17703171439908708832013-07-31T14:18:02.756-07:002013-07-31T14:18:02.756-07:00Hi,
If I use the visual studio server or IIS expr...Hi,<br /><br />If I use the visual studio server or IIS express, the program runs well, but when I used the IIS of the local computer, regular web pages worked but not for those that need SQL server connections. I use window authentication for SQL server, but the integrated security=SSPI method didn't work, and I check the web, that seems to be the case in general. I noticed you used SQL server user id and password, but I don't have one, and I tried to set up, but it didn't work.<br /><br />Can you please tell how you did that? You have the localhost/WebApplication address, so you should be using the local IIS other than IIS express or visual studio's IIS.<br /><br />Can you answer either here or email me at san.cui@gmail.com Please delete my email address, if you post the question on the web.<br /><br />ThanksAnonymousnoreply@blogger.com