Howto delete AccountExpirationDate

Posted on 2009-07-12
Last Modified: 2012-05-07
I know how to set the AccountExpirationDate, but I do not know how to delete it? (I tried to set the Date to nothing, but that does not work.)

Dim Fieldname As String = "AccountExpirationDate"

        Dim dt As Date = _getDate(fieldname)

        Dim type As Type = mCurUsr.NativeObject.GetType

        If value.Ticks = 0 Then

            If Not dt.Ticks = 0 Then


                type.InvokeMember(Fieldname, BindingFlags.SetProperty, Nothing, mCurUsr.NativeObject, New Object() {value})

                mF &= ", " & Fieldname

            End If


            If Not dt.Ticks = 0 Then dt.AddDays(-1)

            If Not value.Date = dt.Date Then


                type.InvokeMember(Fieldname, BindingFlags.SetProperty, Nothing, mCurUsr.NativeObject, New Object() {value})

                mF &= ", " & Fieldname

            End If

        End If

Open in new window

Question by:ofnet
LVL 31

Accepted Solution

Henrik Johansson earned 50 total points
ID: 24835623
To set the user to never expire, the AccountExpires attribute is set to 9223372036854775807 (January 1st, 1601)

Author Closing Comment

ID: 31602602
The Date 1/1/1601 did not work, but 1/1/1970 did work. Greate. Thx.

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Move (NOT migrate) from SBS 2008 to Server 2016 (no Exchange) 8 109
edit user account 1 29
How do i move AD Contacts to O365? 2 30
Distribution groups exchange 2013 6 43
A short article about problems I had with the new location API and permissions in Marshmallow
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now