Click here to Skip to main content
15,900,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi..
I want to decline Login suppose after 6:30 PM...how should i do this in asp.net with c#

Please help me..

Thanks in advance.

Regards,
Vishal
Posted
Comments
Abdul Quader Mamun 14-Jul-12 11:22am    
Which type of authentication method you are using for login?
Vishal Bhoge 14-Jul-12 11:25am    
Windows Authentication..and i want it on Login_Click..
Abdul Quader Mamun 14-Jul-12 11:50am    
Are you using ASP.NET login control for this?
Vishal Bhoge 14-Jul-12 23:54pm    
No...i m using simple login button control..i am fetching time from database and want to compare with 6:30 PM as specified time...

One way (of many) might be to check the time on the click event of the login button. Compare the time to your timem, if it is more than that time, decline. You might also want to take into account the timezone of the user.

See here[^] for a few different ways to compare times.

And here[^].
 
Share this answer
 
Comments
Vishal Bhoge 14-Jul-12 23:57pm    
thanks a lot..
http://msdn.microsoft.com/en-us/library/ff647405.aspx[^]


1.Check that your ASP.NET application is not configured for impersonation by ensuring that impersonate is set to false on the <identity> element in the Web.config file.
...

XML
<system.web>
 ...
 <authentication mode="Windows"/>
 <identity impersonate="false"/>
 ...
</system.web>
...

2.Obtain the authenticated user's Windows token.
C#
IIdentity WinId= HttpContext.Current.User.Identity;
WindowsIdentity wi = (WindowsIdentity)WinId;

3.Use the authenticated user's Windows token to temporarily impersonate the original user and remove the impersonation token from the current thread when you are finished impersonating.

C#
// Temporarily impersonate the original user.
WindowsImpersonationContext wic = wi.Impersonate();
try
{
  // here you will check time
  // Access resources while impersonating.
}
catch
{
  // Prevent exceptions propagating.
}
finally
{
  // Revert impersonation.
  wic.Undo();
}




This article will help you to solve this problem.
 
Share this answer
 
v3
Comments
Abdul Quader Mamun 14-Jul-12 12:02pm    
Is this helpful then don't be late to voting me.
Vishal Bhoge 15-Jul-12 0:01am    
yes..its helpful..but simply i want to put in if condition..like

current time> 6:30 PM
then login block
else
move to next page
Abdul Quader Mamun 15-Jul-12 0:04am    
have you got solution for this already?

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