我搜索了很長時間,我可以如何定義羣組的允許登錄小時數,例如可以通過Active Directory中的帳戶選項卡對用戶進行操作。使用Active Directory的羣組允許登錄小時數
我已經在c#中有一個類,可以通過幫助'logonhours'屬性使查詢返回用戶所有允許的小時數列表。
public byte[] GetLogonHours(string userName, string password, string path)
{
DirectoryEntry entry = this.GetUserAccount(userName, path);
return (byte[])entry.Properties["logonHours"].Value;
}
public DirectoryEntry GetUserAccount(string username, string path)
{
using (DirectoryEntry objRootEntry = new DirectoryEntry(path))
{
using (DirectorySearcher objAdSearcher = new DirectorySearcher(objRootEntry))
{
objAdSearcher.Filter = "(&(objectClass=user)(samAccountName=" + username + "))";
SearchResult objResult = objAdSearcher.FindOne();
if (objResult != null)
{
return objResult.GetDirectoryEntry();
}
}
}
return null;
}
我用這篇文章來幫助我理解我怎麼可以查詢登錄時間:
明白,我不想一個功能,知道這是重要的,當最後一個用戶已被記錄的時間。我擁有的功能是防止用戶在某些時刻記錄日誌。
我想要的是一個功能,可以爲一組用戶應用登錄時間,我可以使用c#查詢Active Directory以獲取這些登錄時間信息。
非常感謝。