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 220079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:54:18+00:00 2026-05-11T18:54:18+00:00

I have a .NET MVC (1.0) application that is using the ActiveDirectoryMembershipProvider to authenticate

  • 0

I have a .NET MVC (1.0) application that is using the ActiveDirectoryMembershipProvider to authenticate users, and this is working fine as is. After a successful authentication, I am creating a custom profile in SQL for that user (AD username, email, etc).

In one part of the application I am sending email alerts to users, and I am looping though users from the local SQL table that holds the AD UserName, mentioned above. Prior to sending the alert, I would like to verify that the user we are sending to is still a valid (i.e. active) user in AD. How can I check this without the password of the current user in my loop?

I was hoping to do soemthing like this…

MembershipUser adUser= Membership.GetUser(userName); //I have the username from the loop
bool isValid = adUser.isValid; //I know this is not a real property

I know that there is no such property called “isValid” — but does anyone know what property I should use? If MembershipUser is of no use, then I assume that I need to write some code invoking the System.DirectoryServices.ActiveDirectory namespace? If so, what property should I be checking in AD to see if the user is valid? And by “valid,” I mean that the user still works for the company in question, and is able to sign-in via AD. I am not concerned with the user’s group membership in AD.

Thanks,

Mike

  • 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-05-11T18:54:18+00:00Added an answer on May 11, 2026 at 6:54 pm

    You basically need to check the user’s userAccountControl flag for the disabled flag.

    Once you have your DirectoryEntry for the user in question (userAccount), you can check for account disabled and account locked out like this:

    // get the "userAccountControl" property
    int uac = Convert.ToInt32(userAccount.Properties["userAccountControl"][0]);
    
    const int ADS_UF_ACCOUNTDISABLE = 0x00000002;
    const int ADS_UF_LOCKOUT = 0x00000010;
    
    bool accountIsDisabled = (uac & ADS_UF_ACCOUNTDISABLE) == ADS_UF_ACCOUNTDISABLE;
    bool accountIsLockedOut = (uac & ADS_UF_LOCKOUT) == ADS_UF_LOCKOUT;
    

    Marc

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this ASP.NET MVC application that I now want to separate out the
Background: I have an ASP.NET MVC application that wraps controller actions in a TransactionScope
I have an ASP.NET MVC application that also employs the typical NHibernate / Castle
I have an ASP.Net MVC application and I am using StructureMap within MVC to
I have an asp.net mvc calendar application (using jquery ui datepicker) and i am
My application I have an application design that looks like this: web application layer
I have an ASP.NET MVC 2 application with a custom StructureMap controller factory to
This is going to sound quite bizarre. I have one ASP .NET MVC 2
I have an approach in mind for an image viewer in a web app,
I would like to get opinion on the best way to manage the following

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.