Link to home
Start Free TrialLog in
Avatar of EfrenM
EfrenMFlag for United States of America

asked on

VB .net and Active Directory Account Expiration Date

Hi all
i am trying to add a expire date to the account with VB i found the code below and it works as long as i use two digit months ex i put 12/1/2012 and in  the attribute it says 12/1/2012 12:00:00 am,
but if i put 1/1/2012 12:00:00 am then the attribute says 12/31/2011 11:00:00 pm. any ideas what is going on?
Dim adpath As String
        Using de As New DirectoryEntry(adpath)
            Dim deUser As DirectoryEntry = New DirectoryEntry(usr)
            Dim ObjUser
           
 ObjUser = GetObject(deUser.Path)
 ObjUser.AccountExpirationDate = "1/1/2012 12:00:00 AM"
            ObjUser.SetInfo()

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of EfrenM

ASKER

ok i got it working
i added 01/1/2012 1:00 <-
Dim adpath As String
        Using de As New DirectoryEntry(adpath)
            Dim deUser As DirectoryEntry = New DirectoryEntry(usr)
            Dim ObjUser
           
 ObjUser = GetObject(deUser.Path)
 ObjUser.AccountExpirationDate = "1/1/2012 1:00"
            ObjUser.SetInfo()

Open in new window