活动目录AD 取用户过期时间accountExpires
2011-08-12 17:17
399 查看
今天整了一天时间,终于可以取到accountExpires
并转换为DateTime时间。
private long LongFromLargeInteger(object largeInteger)
{
System.Type type = largeInteger.GetType();
int highPart = (int)type.InvokeMember("HighPart", System.Reflection.BindingFlags.GetProperty, null, largeInteger, null);
int lowPart = (int)type.InvokeMember("LowPart", System.Reflection.BindingFlags.GetProperty, null, largeInteger, null);
return (long)highPart << 32 | (uint)lowPart;
}
DateTime LargeIntToDateTime(ActiveDs.LargeInteger li)
{
long lTime;
lTime = (long)li.HighPart;
lTime <<= 32;
lTime |= (uint)li.LowPart;
return System.DateTime.FromFileTime(lTime);
}
ActiveDs.LargeInteger pwdLastSet = child.Properties["pwdLastSet"].Value as ActiveDs.LargeInteger;
if ((accountExpires.HighPart == Int32.MaxValue) && (accountExpires.LowPart == -1))
{
//有效时间
//时间总是相差1天,所以我加了一个 -1
String dt=LargeIntToDateTime(accountExpires).AddDays(-1).ToString()
}
largeInteger 找不能命名空间了吧?
引用com 组件:Active DS Type Library
接下来设置这个属性,就比较方便了
using System.Reflection;
// Get the native object.
Type type = usr.NativeObject.GetType();
Object adsNative = usr.NativeObject;
// Use the Type.InvokeMember method to invoke the
// AccountExpirationDate property setter.
type.InvokeMember(
"AccountExpirationDate",
BindingFlags.SetProperty,
null,
adsNative,
new object[]{"12/29/2004"});
// Commit the changes.
usr.CommitChanges();
The following C# example shows how to use the InvokeSet method to set the value of the IADsUser.AccountExpirationDate property.
// Use the DirectoryEntry.InvokeSet method to invoke the
// AccountExpirationDate property setter.
usr.InvokeSet(
"AccountExpirationDate",
new object[] {new DateTime(2005, 12, 29)});
// Commit the changes.
usr.CommitChanges();
并转换为DateTime时间。
private long LongFromLargeInteger(object largeInteger)
{
System.Type type = largeInteger.GetType();
int highPart = (int)type.InvokeMember("HighPart", System.Reflection.BindingFlags.GetProperty, null, largeInteger, null);
int lowPart = (int)type.InvokeMember("LowPart", System.Reflection.BindingFlags.GetProperty, null, largeInteger, null);
return (long)highPart << 32 | (uint)lowPart;
}
DateTime LargeIntToDateTime(ActiveDs.LargeInteger li)
{
long lTime;
lTime = (long)li.HighPart;
lTime <<= 32;
lTime |= (uint)li.LowPart;
return System.DateTime.FromFileTime(lTime);
}
ActiveDs.LargeInteger pwdLastSet = child.Properties["pwdLastSet"].Value as ActiveDs.LargeInteger;
if ((accountExpires.HighPart == Int32.MaxValue) && (accountExpires.LowPart == -1))
{
//有效时间
//时间总是相差1天,所以我加了一个 -1
String dt=LargeIntToDateTime(accountExpires).AddDays(-1).ToString()
}
largeInteger 找不能命名空间了吧?
引用com 组件:Active DS Type Library
接下来设置这个属性,就比较方便了
using System.Reflection;
// Get the native object.
Type type = usr.NativeObject.GetType();
Object adsNative = usr.NativeObject;
// Use the Type.InvokeMember method to invoke the
// AccountExpirationDate property setter.
type.InvokeMember(
"AccountExpirationDate",
BindingFlags.SetProperty,
null,
adsNative,
new object[]{"12/29/2004"});
// Commit the changes.
usr.CommitChanges();
The following C# example shows how to use the InvokeSet method to set the value of the IADsUser.AccountExpirationDate property.
// Use the DirectoryEntry.InvokeSet method to invoke the
// AccountExpirationDate property setter.
usr.InvokeSet(
"AccountExpirationDate",
new object[] {new DateTime(2005, 12, 29)});
// Commit the changes.
usr.CommitChanges();
相关文章推荐
- TurboMail 邮件服务器与微软活动目录(AD)实现用户数据同步和验证
- windows server 2012 AD 活动目录部署系列(三)加入域并创建域用户
- SharePoint 2010中重置windows 活动目录(AD)域用户密码的WebPart(免费下载)
- SharePoint 2010中重置windows 活动目录(AD)域用户密码的WebPart(免费下载)
- SharePoint 2010中重置windows 活动目录(AD)域用户密码的WebPart(免费下载)
- AD(活动目录)批量创建用户!
- SharePoint 2013中修改windows 活动目录(AD)域用户密码的WebPart(免费下载)
- 重置windows 活动目录(AD)域用户密码
- SharePoint 2013中修改windows 活动目录(AD)域用户密码的WebPart(免费下载)
- 活动目录用户属性与AD字段对照表
- .net中,如何获得活动目录(AD)上的密码失效时间?
- 使用ADRecycleBin还原AD活动目录用户组织对象
- 活动目录用户属性与AD字段对照表
- windows sever2008 r2 活动目录(AD)搭建FTP隔离用户
- SharePoint 2013中修改windows 活动目录(AD)域用户密码的WebPart(免费下载)
- windows server 2012 AD 活动目录部署系列(四)用户资源的权限分配
- 搭建AD活动目录的优势
- win2008安装活动目录AD后的检查
- windows server 2012 AD 活动目录部署系列(九)域控制器的常规卸载
- 在PHP中利用LDAP通过活动目录(Active Directory)实现域用户登录验证的办法