473,401 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Change password using Forms Authentication

Hi there! I'd like to know if anyone out there can give me a helping hand.
I've developed an asp.net application that uses Forms Authentication.

Question:

I'd like to give users the ability that after every 30 days, they must
change their passwords. So if the 30 days have passed, and user FELIX tries
to log on, I want this user to be redirected to a ChangePwd.aspx web page.
Once the user changes his/her password, he/she must be taken back to the
login screen so that he/she can log on with his/her new password.

Any one has an idea on how to do this? sample code?

Thanks in advance,

Felix
Jun 21 '06 #1
2 2631
Check last date of change password every login than count 30 days or 90
days.

DateTime LastChangePassword;
int DayOfPassword;

LastChangePassword.AddDays(DayOfPassword);

if (LastChangePassword > DayOfPassword)
{
Response.Redirect("ChangePassword.aspx");
}

Jun 21 '06 #2
divati,

First of all, I'd like to thank for the quick response.

On the other hand, I'd tried your solution before posting the question. I
think that it'd be better to explain in detail of what I've done so far.

Here's the code I've written on the cmdLogin_ServerClick() event procedure:

If Page.IsValid Then
Dim accountSystem As New
ClubCorporativoCOM.Versatec.ClubCorporativo.Seguri dad
Dim userId As String =
accountSystem.LoginIsValid(txtUserName.Value, txtUserPass.Value)
If userId = "1" Then
Dim objPWD As New
ClubCorporativoCOM.Versatec.ClubCorporativo.Seguri dad, intRetCode As
Integer, strRetMessage As String
objPWD.VerificaPWD(txtUserName.Value, intRetCode,
strRetMessage)
If intRetCode = 0 Then
Response.Redirect("CambiarPWD.aspx") <== HERE'S THE
ERROR!!!
End If

FormsAuthentication.SetAuthCookie(txtUserName.Valu e, False)
If
CType(ConfigurationSettings.AppSettings("useDefaul tPageFromLogin"), Boolean)
= False Then
Response.Redirect(ConfigurationSettings.AppSetting s("redirectDefaultUrl").ToString)
Else
Response.Redirect(FormsAuthentication.GetRedirectU rl(txtUserName.Value,
False))
End If
Else
Me.lblMsg.Visible = True
Me.lblMsg.Text = "<" & "br" & ">" & strErrMsg & "<" & "br" &
">"
End If
End If

The problem lied as soon as I executed the response.redirect method because
it took me again to the logon web page. Why??? please, continue reading...
But then I studied the code line by line and found out that the infamous
error was the line:
FormsAuthentication.SetAuthCookie(txtUserName.Valu e, False)
had to be called before the lines:
If intRetCode = 0 Then
Response.Redirect("CambiarPWD.aspx") <== HERE'S THE
ERROR!!!
End If

The reason for this I guess was that, by the time the response.redirect line
was called the user had not yet been authenticated and therefore,
FormsAuthentication module redirected me to the logon screen. So first I
had to be authenticated, then create the cookie (by the SetAuthCookie
method) and then... had to redirect to the CambiarPWD.aspx to proceed by
changing the password.

At the end, it worked great!.

Thanks again for the help and patience.
Felix
"divati" <ak****@gmail.com> wrote in message
news:11**********************@b68g2000cwa.googlegr oups.com...
Check last date of change password every login than count 30 days or 90
days.

DateTime LastChangePassword;
int DayOfPassword;

LastChangePassword.AddDays(DayOfPassword);

if (LastChangePassword > DayOfPassword)
{
Response.Redirect("ChangePassword.aspx");
}

Jun 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tony | last post by:
Please help, I've scoured the web but cannot find an answer to this! I want to use WebRequest to get the contents of a web page. The trouble is, the page require you to go to a login page (using...
2
by: Rod | last post by:
I have a requirement in which I need to allow the user to log into our ASP.NET application, but also be able to change their Windows password, if it is expired. I had thought that Windows...
4
by: sunniyeow | last post by:
Hi, My question is regarding password protecting 2 different folders inside a single virtual directory using forms authentication method. Easier if I illustrate things out... - <authentication...
2
by: J | last post by:
Hello. I apologize if this isn't the appropriate group for this question but I was wondering if it's possible to allow regular windows domain users to change their passwords through an .asp page? ...
5
by: nick | last post by:
I need to create a simple asp.net application that use password protect some html pages. The html page provider doesn't know asp.net. And the host doesn't allow me to create user accounts. ...
1
by: jeffg | last post by:
I have a web site that I use forms authentication on. I am trying to implement a password recovery tool, but am unable to get beyond the login screen to get to my PasswordRecovery page. My...
1
by: Sankalp | last post by:
Hi, I am using VB 2005. My application has many data bound controls. The connection is stored in the app.config file. I want the application to start with a default connection string and while...
3
by: =?Utf-8?B?QXhlbCBEYWhtZW4=?= | last post by:
Hi, we've got a strange problem here: We've created an ASP.NET 2.0 web application using Membership.ValidateUser() to manually authenticate users with our website. The problem is: If the...
2
by: Mel | last post by:
We have a private website, we call it a portal, where people can login and get quotes and such. When you go to the portal URL (https:// example.url.com) a small dialog appears (I believe this is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.