473,899 Members | 3,305 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Active Directory "pwdLastSet " Value issue

295 Recognized Expert Contributor
Hello to start off i have a VBScript not VB. I am not sure where it goes but I figured this would be a good place to start.

So I am querying AD to pull the Last Data an individual set their password. I have that working just fine but I have ran into a snag where not all individuals have a Last Password Set value. My code that I have to convert big integer into date handles the value which is null or to be more specific does not exist. However it returns the wrong date, I know its the wrong date because I have had individuals reset their password to confirm that its not an actual reset issue.

I am using a standard aDODB connection into AD and this is how i am pulling the Password Set Value

Expand|Select|Wrap|Line Numbers
  1. Return Value for Password Last Set
  2. set objDate = adoRecordset.Fields("pwdLastSet").Value
  3. strPwdLastSet = Integer8Date(objDate,lngBias)
  4. strPwdExpDate = DateAdd("d", numDays, strPwdLastSet)
Below is the large integer code
Expand|Select|Wrap|Line Numbers
  2. Function LargeIntegerToDate (value)
  3. '====================================================================================
  4. '
  6. 'http://www.selfadsi.org/ads-attributes/user-pwdLastSet.htm -doesn't handle error
  7. '
  8. '
  9. '
  10. '======================================================================================
  11. ' Function to convert Integer8 (64-bit) value to a date, adjusted for
  13. 'takes Microsoft LargeInteger value (Integer8) and returns according the date and time
  15.     'first determine the local time from the timezone bias in the registry
  16.     Set sho = CreateObject("Wscript.Shell")
  17.     timeShiftValue = sho.RegRead("HKLM\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias")
  19.     If IsArray(timeShiftValue) Then
  20.         timeShift = 0
  21.         For i = 0 To UBound(timeShiftValue)
  22.             timeShift = timeShift + (timeShiftValue(i) * 256^i)
  23.         Next
  24.     Else
  25.         timeShift = timeShiftValue
  26.     End If
  28.     'get the large integer into two long values (high part and low part)
  29.     i8High = value.HighPart
  30.     i8Low = value.LowPart
  31.     If (i8Low < 0) Then
  32.            i8High = i8High + 1 
  33.     End If
  35.     'calculate the date and time: 100-nanosecond-steps since 12:00 AM, 1/1/1601
  36.     If (i8High = 0) And (i8Low = 0) Then 
  37.         LargeIntegerToDate = #1/1/1601#
  38.     Else +
  39.         LargeIntegerToDate = #1/1/1601# + (((i8High * 2^32) + i8Low)/600000000 - timeShift)/1440 
  40.     End If
  42. End Function
Now here is the kicker 3 days ago i had found a module that did this and actually accounted for the null value and worked. I lost it and have not been able to recover the actual value. Anyone have any suggestions.
Nov 7 '14
11 4698
295 Recognized Expert Contributor
So closing the loop here on this problem. Script is perfect, (as it is in the eye of the beholder) and it seems the only issue i was having was not running the script as an administrator. Image that, i was running the script as my self (who is an admin) but not elevating it at the system. Miss the good old days of windows.

Feb 10 '15 #11
12,516 Recognized Expert Moderator MVP
Glad you got the issue sorted out. We must have different group policies, I don't need to elevate the script to run it.
Feb 10 '15 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Jay Chan | last post by:
We have just installed a SQL Server 2000 (SP 3A) onto a computer that has Windows-2003 Server on it. Now, we cannot get access to that database server from other computers. Seem like this may be an issue with Active Directory. Our network consists of Windows-2000 Servers (SP 4) and Windows-2000 workstations and Windows-XP workstations. We also have SQL Server 2000 (SP2) in three Windows-2000 servers. All work fine. Recently, we get a...
by: Mario Rodriguez | last post by:
Hi people. I have a problem adding users to Win2003 active directory programatically. When I execute my app throws the following exception: .................The specified directory service attribute or value does not exist........... Exactly the same code works fine on my win2000 active directory. My app include the use of the extensionAtributes and I'm not sure if the extensionAttributes feature was removed from win2003 Active...
by: ASGMikeG | last post by:
Hi, How do I find the user object for the current user in Active Directory i.e. the user running my program ? Regards Michael
by: Frank_00001 | last post by:
I'm trying to use Active Directory to get a list of users that are in the same directory as the logon user. I'm trying to do this as a Web App written in C# using Windows Security and Impersonation. When running from the local host I have no problem; but when I try the same thing remotely I get the error "System.Runtime.InteropServices.COMException" on the second hit on Active Directory, the first hit works fine. I used to get the same...
by: Peter | last post by:
I am trying to get values from Global Address List in Outlook through Active Directory I am able to get all the values except the 'location'. There seems to be no 'location' variable Is there a way to retreive the location form GAL? Here is the code: DirectoryEntry entry = new DirectoryEntry(_adPath, _adUserName, _adPassword, AuthenticationTypes.Secure); //
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem I have run into I am not sure how to fix, and really not sure what is causing it. Here's what is going on (test server - Windows 2003 Server): I have a page in a folder (under anonymous authentication in IIS6) that has a link on it that...
by: Patrick | last post by:
I have an ASP.NET page that searches for someone in the corporate Active Directory. It had been working fine until recently when I changed from Basic Authentication on IIS6 back to Integrated Windows authentication. The error occurs on the FindAll method. The exceptions are as follows. anyway of getting the code working with Integrated Windows authentication (too annoying for user to enter user-name/password). Note I do need to use...
by: Phil Kelly | last post by:
Hi! Is it possible to set the value of an Active Directory attribute to be empty? I've tried to set the 'company' attribute as follows: myRepEntry.Properties(strAttrName)(0) = Nothing but I get an error stating that the value cannot be NULL.
by: Arthur | last post by:
Hi All, I would like to get the name of the user given their networkID, is this something Active Directory would be useful for?(For intranet users) If so, can you please point me to some sample code/examples? Thanks in advance, Arthur
by: shrikant kesh | last post by:
Hi All I am using windows 2008 R2 Server and trying to Add a user in active directory . I am able to save user ID of length less than 20 Characters.But when I am trying to increase this value to 30 characters then I am getting the error.
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.