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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:39:32+00:00 2026-05-18T01:39:32+00:00

I have searched the site for information and found this: ASP.NET C# Active Directory

  • 0

I have searched the site for information and found this:
ASP.NET C# Active Directory – See how long before a user's password expires

which explains how to get the value of when the password expires as per Domain Policy.

My question is this: what if the user has an OU Group Policy that has a different MaxPasswordAge value, overriding the one specified in Domain Group Policy? How to programatically get the OU’s Group Policy Object?

Edit: To make this question a little bit more clear, I am adding this edit. What I am after is to being able to tell when user’s password expires. As far as I understand that date value can either be governed by domains local policy or by group object policy. I have a Linq2DirectoryService Provider that translates Linq to Ldap queries. So an LDAP query to get the date expiration value would be optimal for this subj. If you answer includes what objects wrappers supported by .net are included into this equation – it would be a dead on answer!

  • 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-18T01:39:33+00:00Added an answer on May 18, 2026 at 1:39 am

    Let me start with http://support.microsoft.com/kb/323750 which contains Visual Basic and VBScript examples and http://www.anitkb.com/2010/03/how-to-implement-active-directory.html which outlines how the maxPwdAge OU setting impacts computers, not users. It also has a comment pointing to AloInfo.exe as a tool from MS that can be used to get password ages.

    Here is the example:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.DirectoryServices;
    
    namespace LDAP
    {
        class Program
        {
            static void Main(string[] args)
            {
                string domainAndUsername = string.Empty;
                string domain = string.Empty;
                string userName = string.Empty;
                string passWord = string.Empty;
                AuthenticationTypes at = AuthenticationTypes.Anonymous;
                StringBuilder sb = new StringBuilder();
    
                domain = @"LDAP://w.x.y.z";
                domainAndUsername = @"LDAP://w.x.y.z/cn=Lawrence E."+
                            " Smithmier\, Jr.,cn=Users,dc=corp,"+
                            "dc=productiveedge,dc=com";
                userName = "Administrator";
                passWord = "xxxpasswordxxx";
                at = AuthenticationTypes.Secure;
    
                DirectoryEntry entry = new DirectoryEntry(
                            domain, userName, passWord, at);
    
                DirectorySearcher mySearcher = new DirectorySearcher(entry);
    
                SearchResultCollection results;
                string filter = "maxPwdAge=*";
                mySearcher.Filter = filter;
    
                results = mySearcher.FindAll();
                long maxDays = 0;
                if(results.Count>=1)
                {
                    Int64 maxPwdAge=(Int64)results[0].Properties["maxPwdAge"][0];
                    maxDays = maxPwdAge/-864000000000;
                }
    
                DirectoryEntry entryUser = new DirectoryEntry(
                            domainAndUsername, userName, passWord, at);
                mySearcher = new DirectorySearcher(entryUser);
    
                results = mySearcher.FindAll();
                long daysLeft=0;
                if (results.Count >= 1)
                {
                    var lastChanged = results[0].Properties["pwdLastSet"][0];
                    daysLeft = maxDays - DateTime.Today.Subtract(
                            DateTime.FromFileTime((long)lastChanged)).Days;
                }
                Console.WriteLine(
                            String.Format("You must change your password within"+
                                          " {0} days"
                                         , daysLeft));
                Console.ReadLine();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well I have searched and haven't found any information on this or whether it's
I have searched this site for an answer and found many responses to unsigned/signed
I have searched this site top to bottom yet have not found a single
I have searched this site and Google and even though the idea is pretty
Preface: I am sure this is incredibly simple, but I have searched this site
I have searched for this, and i found that for api less than 12,
I have searched various online resources and found conflicting information about the possibility of
I have searched this site and also googled but can't seem to find the
i have searched this site back and forth withoutfinding a clear answer for what
I have the following code in my Site.Master page of an almost empty ASP.NET

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.