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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:09:11+00:00 2026-06-18T10:09:11+00:00

I want to make a few simple reports from Active Directory. Following discussions, etc.

  • 0

I want to make a few simple reports from Active Directory. Following discussions, etc. I found that if I use .NET FW 3.5 and up, it is appropriate to use PrincipalContext. I would like to understand principles and what I can do with this new feature (unlike DirectoryEntry).

Code skeleton

// create your domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, 
    "YOURDOMAIN", "OU=SomeOU,DC=YourCompany,DC=com");

// define a "query-by-example" principal - here, we search for a UserPrincipal 
// which has a password that will expire in 3 days or less
UserPrincipal userTemplate = new UserPrincipal(ctx);
userTemplate.AdvancedSearchFilter.AccountExpirationDate(DateTime.Today.AddDays(3), MatchType.LessThanOrEquals);

// instantiate searcher
PrincipalSearcher searcher = new PrincipalSearcher(userTemplate);

// enumerate matching users
foreach (Principal foundPrincipal in searcher.FindAll())
{
    UserPrincipal foundUser = (foundPrincipal as UserPrincipal);

    if (foundUser != null)
    {
        // do something with users found - e.g. send e-mail
    }
}

It is possible by code up add this properties for login to LDAP?:

  • what LDAP is used (version 2 or 3)
  • how set port on which LDAP is running
  • how to work if I need SSL connection? (different port, must be special requirements)

Furthermore, can I do with AdvancedSearchFilter this conditions?
(I found only AccountExpirationDate and AccountLockoutDate)

  • users password will expire in the near future
  • users password has expired
  • check if the user’s password can expire
  • users account expires (account, no password)
  • expired users account (account, no password)
  • user account not expired
  • 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-18T10:09:12+00:00Added an answer on June 18, 2026 at 10:09 am

    sorry for the late reply. The solution I found these two links, which describes all the information. Just as it only needs to combine with the code above.

    retrieve the value of “Minimum Password Length” in domain password policy

    House of Derek – Password expiration email utility

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

Sidebar

Related Questions

I'm building a few SharePoint sites, and I want to make use of zones
I want to write a PHP script that I can use from the command
I have a few simple classes, all extending Doctrine_Record. Now I want to make
I want to use HTML in Crystal Reports. I already found out Crystal reports
I want to make a simple 2d terrain with just a few bumps and
Lets say I want to make few classes to determine behaviour of agents. The
I want to make some modifications to a few selected tick labels in a
I want make a bash script which returns the position of an element from
I want to make, or find, a simple, platform independent concurrency (aka threading) lib
My current project requires extensive use of bit fields. I found a simple, functional

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.