We help IT Professionals succeed at work.
Get Started

Get password expiration from AD in VB 2008

3,012 Views
Last Modified: 2013-12-24
Hi,

From a program, I can retrieve informations from the Active Directory for a specific user. Now, I must find out how to get the password expiration date and let the user change it from my application.

here is the code I did:

        Dim deSystem As New DirectoryEntry("LDAP://SERVER_NT", "dominicg", "gagne")
        deSystem.AuthenticationType = AuthenticationTypes.Secure

        Dim strSearch As String = "sAMAccountName=dominicg"
        Dim dsSystem As New DirectorySearcher(deSystem, strSearch)

        'va chercher nombre de jour d'un password
        Dim test1 As LargeInteger
        test1 = CType(deSystem.Properties("maxPwdAge").Item(0), LargeInteger)
        Dim numDays As Double
        numDays = ((test1.HighPart * 2 ^ 32) + test1.LowPart) / -864000000000@
        Debug.Print("Maximum Password Age: " & numDays)

numdays always give 42.94967296, no matter what value I put in the domain policy.

Is there something wrong the conversion code? I got it from Microsoft MSDN.

thanks a lot!
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE