- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何将 Integer8 类型的值转换为 DateTime 类型的值?特别是,我试图以人类可读的形式获取 accountExpires Active Directory User 属性。 SearchResult.GetDirectoryEntry.Properties("accountExpires")
返回值“9223372036854775807”。
最佳答案
来自 http://www.dotnet247.com/247reference/msgs/19/96138.aspx
An "Integer8" in AD is an object holding two 32 bit properties, called LowPart and HighPArt. Such a property is returned as an generic RCW (__ComObject), what you need to do is unwrap the underlying object or just cast it to a LargInteger COM type. After that you have to combine both properties into a long (64 Bit), if the value represents a date you have to translate the format from FileTime to DateTime.
Following shows how to retrieve "lastLogon" date property. !!! Set a reference to the activeds.tlb, or create an interop library using tlbimp.exe !!!!
// Use a cast ...
li = pcoll["lastLogon"].Value as LargeInteger;
// Or use CreateWrapperOfType
// li = (LargeIntegerClass)Marshal.CreateWrapperOfType(pcoll["lastLogon"].Value,
typeof(LargeIntegerClass));
// Convert to a long
long date = (((long)(li.HighPart) << 32) + (long) li.LowPart);
// convert date from FileTime format to DateTime
string dt = DateTime.FromFileTime(date).ToString();
关于.net - 如何将 Integer8 值转换为 DateTime?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7169749/
我是一名优秀的程序员,十分优秀!