Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi all,

I am trying to retrieve the "Modified" date attribute from active directory using c#. In the ADUC snap-in GUI application this property is located in the "object" tab.

I am using a Directory Search to retrieve the user records, where by "currentUser" below is declared as a DirectoryEntry. The problem I am having is that when I use the "WhenChanged" attribute the date and time returned is not the same as that in the Object tab of the snap-in. When I use the "modifyTimeStamp" attribute a NullRefrenceException is thrown.

Am I using the wrong attribute name for the modified date property in the object tab or is there someone else I have to do to access this property?


currentUser.Properties["whenChanged"].Value.ToString(); currentUser.Properties["modifyTimeStamp"].Value.ToString();


Any help greatly appreciated.
Posted

Hi all,

Worked out, with the help of the links Rod provided, what the problem was with the "WhenChanged" property.

I noticed that the date and time of this property was different when accessing programatically than from the ADUC Snap-in GUI. Basically what was happening was any object that had been modified since the change in British Summer Timer was showing 1 hour behind that of the GUI application. While objects modified previous to the change of British Summer Time were showing the exact same date and time programatically and from the ADUC GUI.

It would appear MS store the "whenChanged" time-stamp not using local time, and instead simply add on 1 hour when it is presented to the user in the GUI.

Thanks for your help anyway Rod, much appreciated.

Bryan
 
Share this answer
 
Have you tried "uSNChanged"?

Also to get a list of what attributes are available have a look at this[^] or this[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900