Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends,

Am working on Asp.net , c#, SQLSERVER 2005.

In my project, A message must be displayed to user if his password expires.

I have a Registration(Add new user) webform in my project. in that i have fields
Firstname, Lastname,DisplayName,Username,Password,IssueDate,ExpiryDate.

While creating New User, Administrator will enter all information of user FN,LN,DN,Username,Pwd,IssueDate,ExpDate.

Generally the issue date will be default like this 19/07/2012(System date) and the admin need to enter only Expiry year like this 2013.

Suppose, if the user passed the year 2013. a message must be displayed while login
"your Password has Expired, Please contact Administrator"


Please help me , how to solve this.


Thanks in ADVANCE.
Posted

Let's say for each user you have a expiry year defined.

You need to fetch the expiry year for a user and compare with today's date's year. If they match then the password has expired and you need to show the prompt.
SQL
SELECT UserID
FROM User
WHERE ExpiryYear >= DATEPART(year,GETDATE())
AND UserID = @currentLoggedInUser

If any data is returned from the query then that user password has expired.
 
Share this answer
 
Comments
sandeep nagabhairava 19-Jul-12 4:34am    
good work sandeep my 5!
Sandeep Mewara 19-Jul-12 4:38am    
Thanks.

sandeep nagabhairava 19-Jul-12 4:40am    
hoo.. unfortunately i for got it... hold this...
you will do a query like this

select 1 from your table where userid= <your userid=""> and getdate = <password expiry="" date="" field="">

if it satisfies 1 will be returned then pass word is expired.
 
Share this answer
 
Comments
Ranjith Reddy CSE 19-Jul-12 4:04am    
am not clear, what is 1. Please explain me boss.
Explain me in detail

Thanks
Ranjith Reddy CSE 19-Jul-12 4:08am    
Suppose if the Users Expiry date is less than todays date. It must display a message like this.

"Your Password has Expired,Please contact administrator"

Thanks , Please help me brothers.
hi ranjit

You try like this i am, showing in 2tier format for just understanding purpose,

bring Expiry date from Database
ex:

SQL
Select Max(ExpiryDate) from TABLE where Username='"+txtusername+"' and Password='"+txtpassword+"'


C#
cn.Open();
Datetime ExpDate;
              dr = cmd.ExecuteReader();

              if (dr.Read() == true)
              {

                ExpDate=convert.todatetime( dr[0].ToString());
              }
              cn.Close();
if(ExpDate<datetime.now.year)>
{
//Show your msg hear
}
else
{
//write yor code hear
}

i hope this will helps you

Thanks&&Regards
Sandeep
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900