Last post May 03, 2011 08:05 AM by Gindy39
May 02, 2011 09:20 AM|Gindy39|LINK
Good day to all,
In my quest to perfecting the web app I'm developing, I was ask to make the web app update the "accountexpire" attribute. I have try diferent forums and the solutions I find, either I don't get them because of my noob status or they just dont work.
My app can take diferent attributes and update them without problems (but later on I'm going to need some help to change how the app writes on the AD because I'm using a old method use here and is so long and confusing, and I bet there is a simpler method,
but thats topic for another post) . Since "accountexpire" uses a INT8 , atleast for me is hard to write for it. I was thinking then to find something to convert a date into a Int8 number, the only one that I found in several web site is the one located in
this link: http://info.izzy.org/Technical/Scripting/Lists/Snippets/DispForm.aspx?ID=2.
When I copy paste the scrip, I get a "Wscript not declare" error. I'm developing in Vb 2008. I can write on the attribute if I use a int8 (64bit) number. I know that the max value is
2^31 - 1 and this one in numbers is 9223372036854775807. I know my app write it because i change the last 3 digits to 000 and when I refresh app to show the accountexpire attribute as it is on the AD it shows the change. So i
know I can write on it but for now just using that long number. I either need a another way that the attibute can take a date or a way to convert a date to that number so it updates the account expiration date to w/e date my bosses want it to expire
Ty for your help
May 02, 2011 01:11 PM|Gindy39|LINK
researching again i found this function that I'm about to try to see if i can convert the date into integer 8 easier than what the script I had did.. if it work i will post back for anyone else that need it can use it as reference
strDateDiffSeconds = DateDiff("s",#1/1/1601#,strDate)
strDateDiffSeconds = strDateDiffSeconds + 172800 'For some reason need to add two days back...
strResult = Cstr(strDateDiffSeconds) & "0000000"
getInteger8Date = strResult
May 03, 2011 04:26 AM|smirnov|LINK
May 03, 2011 08:05 AM|Gindy39|LINK
Yeah the funcion I posted, that I got from another source , >< I miss link to give credits, works like a charm. Here I post it finish and will explain in case someone else use it in the future.
'use to convert Date to Int8 for use in attribute accountexpire of Active Directory
Function getInt8Date(ByVal _Date) As String
Dim _datediffseconds As String 'could be some other type, I just choose string
Dim _resultado As String
_datediffseconds = DateDiff("s", #1/1/1601#, _Date) ' "s" = second interval... will calculate de datediff betwen AD start date set by MS
and the date u want and returns seconds
_datediffseconds = _datediffseconds + 172800 'For some reason it's 2 days off soo add 2 days ( a day has 86,400 seconds)
_resultado = CStr(_datediffseconds) & "0000000" 'These 0's correspond to the hour of the day if im not mistaken, i just use 00:00:00
getInt8Date = _resultado
When using in a procedure just invoque function and place date in betwen ( ) and should return date in 64-bit, a nice long number. I did calculation manually (took a long while) and verify in AD if changes made and it worked .
I did find something curious, Windows provides this Int8 to date converter which is called W32tm.exe. Using it to verify the date I calculate to INT8, it returns the date I used + 1 day and 19 hrs or so ,lol... No clue here but well, AD tells me the date
I want, is the date set.
Have a good one, time for next post with next question.