我需要通过c#更新AD用户的登录时间。
用户登录时间为:
- 周一 - >星期五:早上7点到晚上7点
- 周六:早上7点到下午1点
- 星期日:不登录
以下是我的代码,但时间未设置为真
DirectoryEntry user = ad.GetUser("nguyen.abc");
//////////////////////////
var newTest = new List<TestCRUD_AD.LogonTime>();
var zone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
newTest.Add(new TestCRUD_AD.LogonTime(DayOfWeek.Monday, new DateTime(2011, 1, 1, 7, 0, 0), new DateTime(2011, 1, 1, 17, 30, 0), zone));
newTest.Add(new TestCRUD_AD.LogonTime(DayOfWeek.Tuesday, new DateTime(2011, 1, 1, 7, 0, 0), new DateTime(2011, 1, 1, 17, 30, 0), zone));
newTest.Add(new TestCRUD_AD.LogonTime(DayOfWeek.Wednesday, new DateTime(2011, 1, 1, 7, 0, 0), new DateTime(2011, 1, 1, 17, 30, 0), zone));
newTest.Add(new TestCRUD_AD.LogonTime(DayOfWeek.Thursday, new DateTime(2011, 1, 1, 7, 0, 0), new DateTime(2011, 1, 1, 17, 30, 0), zone));
newTest.Add(new TestCRUD_AD.LogonTime(DayOfWeek.Friday, new DateTime(2011, 1, 1, 7, 0, 0), new DateTime(2011, 1, 1, 17, 30, 0), zone));
newTest.Add(new TestCRUD_AD.LogonTime(DayOfWeek.Saturday, new DateTime(2011, 1, 1, 7, 0, 0), new DateTime(2011, 1, 1, 12, 30, 0), zone));
var newResult = PermittedLogonTimes.GetByteMask(newTest);
//var hoursResult = PermittedLogonTimes.GetLogonTimes(newResult);
user.Properties["logonHours"].Add(newResult);
user.CommitChanges();