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();
The error thrown is errMsg = "System.Runtime.InteropServices.COMException (0x80004005): Unspecified error\r\n\r\n at System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.PutEx(Int32 lnControlCode, String bstrName, Object vProp)\r\n at System.DirectoryServices.PropertyValueColl...
Please advise. If it was a permission issue I would have gotten an error on the first line ... On premise AD (not Azure) Thanks
For those who come here with the same issue, this fixed it . . .
Convert.ToString((Int64)DateTime.UtcNow.AddDays(1).ToFileTimeUtc())
See this thread for a more detailed discussion.
User contributions licensed under CC BY-SA 3.0