Solved

LDAP Query - Password Expires

Posted on 2007-11-30
5
2,751 Views
Last Modified: 2011-09-20
Can you tell me why these dont work?

        private TimeSpan GetMaxPasswordAge()
        {
            DirectoryEntry entry = new DirectoryEntry("LDAP://SERVER1:3268");
            entry.AuthenticationType = AuthenticationTypes.Secure;

            DirectorySearcher searcher = new DirectorySearcher(entry, "(objectClass=*)", null, SearchScope.Base);
            SearchResult result = searcher.FindOne();
            TimeSpan maxPwdAge = TimeSpan.MinValue;
            if (result.Properties.Contains("maxPwdAge"))
                maxPwdAge = TimeSpan.FromTicks((long)result.Properties["maxPwdAge"][0]);
           
            return maxPwdAge.Duration();
        }

//-------------------
                    searcher = new DirectorySearcher(entry, filter, new string[] { "maxpwdage" });
                    result = searcher.FindOne();
                    if (result.Properties["pwdLastSet"].Count > 0)
                    {
                        if (result.Properties["pwdLastSet"][0].ToString() != "")
                            pwdLastSet = result.Properties["pwdLastSet"][0].ToString().ToLower();
                    }
0
Comment
Question by:Rowdyone52
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 21

Expert Comment

by:surajguptha
ID: 20383077
are you getting an exception now? what problems are u having?
0
 

Author Comment

by:Rowdyone52
ID: 20383097
The value for result.Properties["maxPwdAge"].Count  and  result.Properties["pwdLastSet"].Count  are always zero.  I dont get an exception.
0
 
LVL 21

Expert Comment

by:surajguptha
ID: 20383136
List out all the properties and see if this property exists in the Search Result properties.
It may not be available or u might have been using the wrong property name
ResultPropertyCollection myResultPropColl;
myResultPropColl = mySearchResult.Properties;
Console.WriteLine("The properties of the " + 
                  "'mySearchResult' are :");
foreach( string myKey in myResultPropColl.PropertyNames)
{
   string tab = "    ";
   Console.WriteLine(myKey + " = ");
   foreach( Object myCollection in myResultPropColl[myKey])
   {
      Console.WriteLine(tab + myCollection);
   }
}

Open in new window

0
 

Author Comment

by:Rowdyone52
ID: 20383669
it isnt available, but I am looking all over the net and it should be.  I cannot figure out why I can't access that property name.
0
 
LVL 21

Accepted Solution

by:
surajguptha earned 500 total points
ID: 20383701
I dont know if this would help you but posting it anyways
http://msdn2.microsoft.com/en-us/library/ms974598.aspx
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question