?
Solved

VB .net and Active Directory Account Expiration Date

Posted on 2011-10-31
2
Medium Priority
?
1,246 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:EfrenM
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 37057903
Have you tried setting it to a datetime object instead of string?
0
 
LVL 2

Author Comment

by:EfrenM
ID: 37058105
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

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

840 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