2015-01-14 28 views
0

我有下面的代碼,給我的用戶的UserAccountControl AD​​屬性的值:Active Directory中的UserAccountControl值不更新用戶鎖定後

$samId = "someUserName" 

$directorySearcher = New-Object System.DirectoryServices.DirectorySearcher 
$directorySearcher.PageSize = 100 
$directorySearcher.SearchScope = [System.DirectoryServices.SearchScope]::Subtree 
$directorySearcher.Filter = "(&(objectClass=user)(|(sAMAccountName=$samId)))" 
$result = $directorySearcher.FindOne() 
$uac = $result.Properties["useraccountcontrol"] 
Write-Host $uaC#output is 512 

我已經正確輸入密碼鎖定這個用戶在AD 3次。 之前,我鎖定了$uac變量是512 但是鎖定了用戶之後,$uac仍然等於512,而它應該等於528

我已設置其他屬性,可以看到,這些被更新的用戶在幾分鐘之內,所以我不認爲它與AD複製有什麼關係,因爲我已經等了大約30分鐘了。

回答

1

自Windows 2003以來,LOCKOUT標誌被替換爲另一個構造屬性msDS-User-Account-Control-Computed。

關於鎖定標記移動:

https://support.microsoft.com/kb/305144/

有關MSD-用戶帳戶,控制計算的:

http://msdn.microsoft.com/en-us/library/cc223393.aspx

+0

我怎麼能訪問使用的DirectoryServices? 我試過$ result.Properties [「msDS-User-Account-Control-Computed」]。 但是這是空的。我也試過沒有破折號,沒有大寫字母等,但它們都是空的。 –

+1

這是一個構造的屬性。您需要明確地刷新它才能加載它。例如'dirEntry.RefreshCache(new [] {「msDS-User-Account-Control-Computed」});'See http://msdn.microsoft.com/en-us/library/ms180877%28v=vs.80%29的.aspx – baldpate

相關問題