Solved

Howto delete AccountExpirationDate

Posted on 2009-07-12
2
651 Views
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
                _setModified()
                type.InvokeMember(Fieldname, BindingFlags.SetProperty, Nothing, mCurUsr.NativeObject, New Object() {value})
                mF &= ", " & Fieldname
            End If
        Else
            If Not dt.Ticks = 0 Then dt.AddDays(-1)
            If Not value.Date = dt.Date Then
                _setModified()
                type.InvokeMember(Fieldname, BindingFlags.SetProperty, Nothing, mCurUsr.NativeObject, New Object() {value})
                mF &= ", " & Fieldname
 
            End If
        End If

Open in new window

0
Comment
Question by:ofnet
2 Comments
 
LVL 31

Accepted Solution

by:
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)
0
 

Author Closing Comment

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

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

789 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