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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:27:09+00:00 2026-05-13T10:27:09+00:00

In our asp.net intranet application we are using windows authentication to authenticate the users.

  • 0

In our asp.net intranet application we are using windows authentication to authenticate the users.

We have recently had a request to give the user a reason for why they cannot login. For example, tell the user they can’t login because their password has expired vs they can’t login because their account is locked out.

When an account is locked out or the password has expired, the user cannot log on to the application. IIS will deny the access and redirect the user to the Access Denied (401) page after 3 login attempts. As the username is not passed to web application when IIS authentication fails, we won’t be able to check if the account is locked out or the password has expired.

Any suggestions on how to get this information?
Are we going to have to move to Forms authentication with an AD provider?

  • 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-13T10:27:09+00:00Added an answer on May 13, 2026 at 10:27 am

    The simple solution to this is to move to forms authentication. But being that I know you did not want to hear that and it is not allowed or a viable solution your next option is to:

    Look into System.DirectoryServices

    Below I’m just pasting some quick code you can play with. Notice how to determine if a user is locked out or not. This is vb.net but can be easily changed to C#.

      Try
                Dim dirEntry As DirectoryEntry
                         dirEntry = New DirectoryEntry("LDAP://yourDomainInfoHere/OU=Users,OU=YourDomain,OU=YourOU,OU=CORP,DC=YourDC,DC=com", "ExecuateAsUser", "Password")
    
                Dim entries As DirectoryEntries = dirEntry.Children
                ' Set login name and full name. 
                Dim newUser As DirectoryEntry = entries.Add("CN=JONNY BOY", "User")
    
                newUser.Properties("sAMAccountName").Add("jboy")
                newUser.CommitChanges()
                newUser.Invoke("SetPassword", "hi2343145gfdtgwdt")
                Dim flags As Integer
    
                flags = CInt(newUser.Properties("userAccountControl").Value)
    
                'enable user below
                newUser.Properties("userAccountControl").Value = flags And Not &H2
    
                'disable user below
                newUser.Properties("userAccountControl").Value = flags Or &H1
    
    
                'lockout property
                Dim l As Long
                l = CType(newUser.Properties("lockoutTime").Value, Long)
    
                If l <> 0 Then
                    'account is locked out
    
                    'so how do we unlock it?
                    'we unlock it by setting it to 0
                    newUser.Properties("lockoutTime").Value = 0
                Else
                    'account is 0 it is NOT locked out
    
                End If
    
                newUser.CommitChanges()
    
                Dim j As DirectoryEntry = entries.Find("CN=JONNY BOY", "User")
                j.Properties("mail").Value = "jon@yahoo.com"
                j.CommitChanges()
            Catch ex As Exception
                Throw ex
            End Try
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 382k
  • Answers 382k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Set the alpha to zero before animating, then animate the… May 14, 2026 at 10:34 pm
  • Editorial Team
    Editorial Team added an answer It does not crash with a recent SIP/PyQt version. May 14, 2026 at 10:34 pm
  • Editorial Team
    Editorial Team added an answer class Foo(object): pass The class above is a "new-style" class… May 14, 2026 at 10:34 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.