如何从Active Directory中检索用户对象的上次修改日期 [英] How to retrieve the last modified date of a user object from Active directory

查看:154
本文介绍了如何从Active Directory中检索用户对象的上次修改日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试使用c#从活动目录中检索已修改"日期属性.在ADUC管理单元GUI应用程序中,此属性位于对象"选项卡中.

我正在使用目录搜索来检索用户记录,其中下面的"currentUser"被声明为DirectoryEntry.我遇到的问题是,当我使用"WhenChanged"属性时,返回的日期和时间与管理单元的对象"选项卡中的日期和时间不同.当我使用"modifyTimeStamp"属性时,会抛出NullRefrenceException.

我是否在对象选项卡中为修改后的日期属性使用了错误的属性名称,或者我还需要其他人来访问此属性?


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


非常感谢任何帮助.

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.

推荐答案

大家好,

借助Rod提供的链接,解决了"WhenChanged"属性出了什么问题.

我注意到,以编程方式进行访问时,该属性的日期和时间与从ADUC管理单元GUI中进行访问的时间和日期有所不同.基本上发生了什么事,因为自英国夏令时的更改显示的时间比GUI应用程序的更改晚了1个小时,因此该对象已被修改.尽管在英国夏令时之前进行了修改的对象通过ADUC GUI编程地显示了完全相同的日期和时间.

看起来,MS会存储"whenChanged"时间戳,而不使用本地时间,而是在GUI中向用户显示时,只需添加1小时即可.

无论如何,感谢您的帮助Rod,非常感谢.

Bryan
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


您是否尝试过"uSNChanged"?

要获取可用属性的列表,请查看 [ [ ^ ].
Have you tried "uSNChanged"?

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


这篇关于如何从Active Directory中检索用户对象的上次修改日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆