如何设置账号过期

时间:2018-09-13 15:53:38

标签: c# asp.net .net active-directory

dirEntry.Properties["userAccountControl"].Value = val & ~0x2; //enable user
//above line no error but below line get error
dirEntry.Properties["accountExpires"].Value = DateTime.UtcNow.AddDays(1).ToFileTimeUtc();
  

抛出的错误是errMsg =   “ System.Runtime.InteropServices.COMException(0x80004005):未指定   错误\ r \ n \ r \ n   System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.PutEx(Int32   lnControlCode,字符串bstrName,对象vProp)\ r \ n位于   System.DirectoryServices.PropertyValueColl ...

请告知。如果是权限问题,我会在第一行出现错误...在前提条件下(不是Azure)谢谢

1 个答案:

答案 0 :(得分:3)

对于那些来这里遇到同样问题的人,此问题已得到解决。 。

Convert.ToString((Int64)DateTime.UtcNow.AddDays(1).ToFileTimeUtc())

有关更详细的讨论,请参见this thread