Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8663993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:07:52+00:00 2026-06-12T17:07:52+00:00

I have an asp.net app which needs to log users into Active Directory using

  • 0

I have an asp.net app which needs to log users into Active Directory using forms authentication (windows authentication isn’t an option with the given requirements).

I’m saving authentication cookies like so:

if (Membership.ValidateUser(model.UserName, model.Password))
{
    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
}

This works great, except that the cookie authenticates the user even after they change their Active Directory password.

Is there a way to tell if the user’s password has changed?

I’m using asp.net MVC3 with .NET 4

What I’ve Tried

If feel like this code should work, however the HttpWebResponse never contains any cookies. Not quite sure what I’m doing wrong.

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Request.Url);
request.CookieContainer = new CookieContainer();

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Cookie authCookie = response.Cookies["AuthCookie"];
if (authCookie.TimeStamp.CompareTo(Membership.GetUser().LastPasswordChangedDate) < 0)
{
    authCookie.Expired = true;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:07:54+00:00Added an answer on June 12, 2026 at 5:07 pm

    Your code should read

    if (Membership.ValidateUser(model.UserName, model.Password))
    {
      string userData = DateTime.Now.ToString();
    
      FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
        username,
        DateTime.Now,
        DateTime.Now.AddMinutes(30),
        isPersistent,
        userData,
        FormsAuthentication.FormsCookiePath);
    
      // Encrypt the ticket.
      string encTicket = FormsAuthentication.Encrypt(ticket);
    
      // Create the cookie.
      Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
    }
    

    Now, when authenticating the user

    HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
    FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.value);
    if (DateTime.Parse(ticket.UserData) > Membership.GetUser().LastPasswordChangedDate)
    {
        FormsAuthentication.SignOut();
        FormsAuthentication.RedirectToLoginPage();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The thing I have a web app (asp.net) which needs to have a feed.
I have an ASP.NET MVC4 app which uses DotNetOpenAuth 4.0.1 to authenticate users with
I have an ASP.NET(2.0 using C#) web app, in which I have a gridview.
I have an ASP.NET app which needs to save files to a network share
I have a asp.net app, in which my start up is inside a directory
I have a textbox in my ASP.NET 4.5 RC WebForms app which needs to
Have an ASP.net web app which works fine for a few days, but then
I'm developing a ASP.Net MVC3 app which will have few hundred videos. I want
So, here's what I'm working on. I have an ASP.NET web app, in which
I have an ASP.NET MVC server app and client code which uses jquery. I'd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.