GPO Troubleshooting: 使用Userenv log來偵錯GPO套用問題

在您的企業環境中,難免會遇到GPO套用的問題,通常來說,這種問題的分析方式是固定的,這篇文章主要透過一些相關的症狀和案例來討論一般GPO套用不到的時候,我們該怎麼辦?

A.啟動UserENV的方式:

Use Registry Editor to add or to modify the following registry entry:

Subkey: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon
Entry: UserEnvDebugLevel
Type: REG_DWORD
Value data: 10002 (Hexadecimal)

修改後重現問題,這個Log檔案的產生路徑如下:

%ystemroot%\Debug\UserMode\Userenv.log

221833 How to enable user environment debug logging in retail builds of Windows
https://support.microsoft.com/default.aspx?scid=kb;EN-US;221833

B.問題分析流程:

針對GPO套用問題

1. 先判斷是套用使用者或是電腦

2. 執行gpresult.exe /V確認上次套用時間和結果

3. 搜尋UserENV.log 中的關鍵字"Starting User" 或 "Starting Computer" 確認使用者或是電腦原則開始套用的時間點。

5. 確認無法套用GPO名稱或是GUID

6. 標記process id 僅針對特定的process id來追蹤,例如:

USERENV(23c.a58) 15:43:27:626 ApplyGroupPolicy: Entering. Flags = e

USERENV(23c.a58) 15:43:27:626 ProcessGPOs:

USERENV(23c.a58) 15:43:27:676 ProcessGPOs:

USERENV(23c.a58) 15:43:27:676 ProcessGPOs: Starting user Group Policy (Async forground) processing...

USERENV(23c.a58) 15:43:27:676 ProcessGPOs:

USERENV(23c.a58) 15:43:27:676 ProcessGPOs:

USERENV(23c.a58) 15:43:27:686 EnterCriticalPolicySectionEx: Entering with timeout 600000 and flags 0x0

USERENV(23c.a58) 15:43:27:686 EnterCriticalPolicySectionEx: User critical section has been claimed. Handle = 0x808

USERENV(23c.a58) 15:43:27:686 EnterCriticalPolicySectionEx: Leaving successfully.

USERENV(23c.a58) 15:43:27:686 ProcessGPOs: Machine role is 2.

USERENV(23c.a58) 15:43:28:106 PingComputer: Adapter speed 100000000 bps

USERENV(23c.a58) 15:43:28:106 PingComputer: First time: 0

其中標記紅色的部分,就是指套用GPO唯一的Process(這個數字每次開機都會不太一樣,但是同一次的套用過程是一樣的)。

以下,我們針對案例來分析:

案例一 Secedit.sdb 有問題,無法套用GPO

Winlogon.log

-------------------------------------------
2008年4月24日 上午 10:15:39
錯誤 1208: 發生延伸錯誤。
建立 database 時發生錯誤。
----設定引擎初始化發生錯誤。----

USERENV(424.1ec) 10:15:39:656 MachinePolicyCallback: Setting status UI to 正在套用電腦設定值...
USERENV(424.1ec) 10:15:39:656 MachinePolicyCallback: Extension requested status UI when status UI is not available.
USERENV(424.1ec) 10:15:39:666 ProcessGPOList: Extension Security returned 0x4b8.
USERENV(424.1ec) 10:15:39:686 ProcessGPOList: Extension Security was able to log data. RsopStatus = 0x0, dwRet = 1208, Clearing the dirty bit
USERENV(424.1ec) 10:15:39:696 ProcessGPOs: Extension Security ProcessGroupPolicy failed, status 0x4b8.
USERENV(424.1ec) 10:15:39:706 ProcessGPOs: -----------------------

Event log

事件類型: 警告
事件來源: SceCli
事件類別目錄: 無
事件識別碼: 1202
日期:  97/4/24
時間:  上午 10:15:39
使用者:  N/A
電腦: ATWA0760
描述:
安全性原則傳播中含有警告。 0x4b8 : 發生延伸錯誤。

若要得到解決這個事件的最佳結果,請以非系統管理員帳戶登入,然後在 https://support.microsoft.com 搜尋 "Troubleshooting Event 1202's"。

請在 https://go.microsoft.com/fwlink/events.asp 查看說明及支援中心,以取得其他資訊。

上述的徵狀,表示Secedit.sdb 有問題,請重新根據下列方式重建secedit.sdb:

1.請按一下 [ 開始 ] , 按一下 執行 , 型別 explorer然後按一下 [ 確定 ]

2.找出並開啟 C:\windows 資料夾

3.在 磁碟機 建立一個新資料夾 C:\windows\OldSecurity. 如果要執行這項操作,請依照下列步驟執行。:

a.Double-click the Windows folder.

b.On the File menu, point to New, and then click Folder.

c.Type OldSecurity, and then press ENTER.

4.將所有檔案, 具有 . log 副檔名從 C:\Windows\Security 資料夾 移動到 C:\Windows\OldSecurity 資料夾 如果要執行這項操作,請依照下列步驟執行。:

a. 連按兩下資料夾,Security 並針對此資料夾下的資料夾及檔案進行檢視。

b. 點選這些您找到的 .log 檔案.請在[ 編輯器 ] 功能表, 按一下 [ 剪下] 。

c. 找出並按一下 [OldSecurity] 資料夾。

d. 在 [ 編輯 ] 功能表, 按一下 [ 貼上 ] 。

5.在 磁碟機C:\Security\Database 中找到 Secedit.sdb 檔案,然後重新命名 Secedit.sdb 為 Secedit.old  檔案 如果要執行這項操作,請依照下列步驟執行。:

a.以滑鼠右鍵按一下 Secedit.sdb , 並按一下 [ 重新命名] 。

b.型別 Secedit.old然後按 ENTER 鍵

6.請按一下 [ 開始 ] , 按一下 執行 , 型別 mmc然後按一下 [ 確定 ]

7.新增安全性設定及分析 ] 嵌入式管理單元。 如果要執行這項操作,請依照下列步驟執行。.

a.按一下 [ 檔案 ] 再、 按一下 [ 新增 / 移除嵌入式管理單元] \ [ 安全性設定及分析 ] 按一下 可用的獨立嵌入式管理單元 清單, 中的及 新增 。

b. 在 [ 新增獨立嵌入式管理單元 ] 對話方塊, 按一下 [ 關閉 ] 。

c. 在 [ 新增 / 移除嵌入式管理單元 ] 對話方塊, 按一下 [ 確定 ] 。

8.在 設定及分析安全性和 , 按一下滑鼠右鍵, 然後按一下 [ 開啟資料庫 。

9.尋找 C\:Windows\Security\Database 資料夾 在[ 檔案名稱] 方塊, 輸入 Secedit.sdb然後按一下 [ 開啟 ]
注意如果您收到一則訊息, 說明該存取被拒, 您可以忽略這個訊息。

10.以滑鼠右鍵按一下 安全性和設定及分析 , 按一下 [ 匯入範本] , 型別 C:\WINDOWS\security\templates\setup security.inf 然後按一下 [ 開啟 ]

11.如果出現提示要重新啟動您的電腦, 重新啟動您的電腦。

案例二 開機時無法套用軟體限制原則,但是開機後卻可以透過Gpupdate /force 正常套用

UserEnv.log

USERENV(518.6b0) 16:55:04:276 ProcessGPOs: Starting computer Group Policy (Background) processing...

USERENV(518.6b0) 16:55:09:369 ProcessGPOs: network name is msft.com

USERENV(518.6b0) 16:55:09:369 ProcessGPOs: User name is: CN=ATWA0880,OU=Disable-Skype,OU=Computer,OU=Corp,DC=msft,DC=com, Domain name is: MSFT

..

USERENV(518.6b0) 16:55:09:432 ProcessGPOs: Domain controller is: \\DCS003. msft.com Domain DN is msft.com

USERENV(518.6b0) 16:55:12:244 ProcessGPO: Searching <CN={0CA6A7D6-D0A9-4C36-905C-17474C7636F8},CN=Policies,CN=System,DC=msft,DC=com>

USERENV(518.6b0) 16:55:12:244 ProcessGPO: Machine has access to this GPO.

USERENV(518.6b0) 16:55:12:244 ProcessGPO: GPO passes the filter check.

USERENV(518.6b0) 16:55:12:244 ProcessGPO: Found functionality version of: 2

USERENV(518.6b0) 16:55:12:244 ProcessGPO: Found file system path of: <\\msft.com\SysVol\msft.com\Policies\{0CA6A7D6-D0A9-4C36-905C-17474C7636F8}>

USERENV(518.6b0) 16:55:12:259 ProcessGPO: Found common name of: <{0CA6A7D6-D0A9-4C36-905C-17474C7636F8}>

USERENV(518.6b0) 16:55:12:259 ProcessGPO: Found display name of: <Disable Skype>

USERENV(518.6b0) 16:55:12:259 ProcessGPO: Found machine version of: GPC is 155, GPT is 155

USERENV(518.6b0) 16:55:13:821 CheckGPOs: No GPO changes but called in force refresh flag or extension Registry needs to run force refresh in foreground processing

….

USERENV(51c.7b0) 17:25:00:491 ProcessGPOs: Processing extension IP 安全性

USERENV(51c.7b0) 17:25:00:491 ReadStatus: Read Extension's Previous status successfully.

USERENV(51c.7b0) 17:25:00:491 CompareGPOLists: The lists are the same.

USERENV(51c.7b0) 17:25:00:491 CheckGPOs: No GPO changes and no security group membership change and extension IP 安全性 has NoGPOChanges set.

由以上這個Log,我們可以看到GPO有正常套用,只是某些GPO原則曾經套用過之後就不會再重複套用(例如軟體派送以及IE 原則的處理), gpupdate /force 主要的目的是全部強迫重新套用一次。我們可以透過修改GPO來強制每次登入的時候都要重新套用一次。

設定"在電腦啟動即登入時要等待網路啟動"->為了讓Windows XP Client不會使用Cached Logon

clip_image001

由於此問題與登錄相關所以啟動"登錄原則處理" 既使沒變動也要更新

clip_image002

可以確認該GPO與哪些相關聯啟動既使沒變更也要進行套用

clip_image004

案例三 用戶端等待套用時間太短,導致群組原則不處理

UserEnv.log

USERENV(23c.440) 15:27:53:138 ProcessGPOs: The DC for domain MSFT is not available at startup. retrying
USERENV(23c.440) 15:27:53:138 RetryDCContactAtMachineStartup: Failed to query GpNetworkStartTimeoutPolicyValue with 2, exit.
USERENV(23c.440) 15:27:53:138 ProcessGPOs: The DC for domain MSFT is not available after retries.
USERENV(23c.440) 15:27:53:138 ProcessGPOs: The DC for domain MSFT is not available. aborting
USERENV(23c.890) 15:29:20:894 GetGPOInfo:  Local GPO's gpt.ini is not accessible, assuming default state.
USERENV(23c.48c) 15:29:22:687 PolicyChangedThread: UpdateUser failed with 6.

Event Log

事件類型: 錯誤
事件來源: Userenv
事件類別目錄: 無
事件識別碼: 1054
日期:  97/4/28
時間:  上午 11:51:47
使用者:  NT AUTHORITY\SYSTEM
電腦: ATWA0219
描述:
Windows 無法取得電腦所屬網域的網域控制站名稱。(指定的網域可能不存在或無法連線。 )。群組原則處理已中止。

請在 https://go.microsoft.com/fwlink/events.asp 查看說明及支援中心,以取得其他資訊。

事件類型: 錯誤
事件來源: Userenv
事件類別目錄: 無
事件識別碼: 1054
日期:  97/4/28
時間:  下午 01:44:43
使用者:  NT AUTHORITY\SYSTEM
電腦: ATWA0219
描述:
Windows 無法取得電腦所屬網域的網域控制站名稱。(指定的網域可能不存在或無法連線。 )。群組原則處理已中止。

請在 https://go.microsoft.com/fwlink/events.asp 查看說明及支援中心,以取得其他資訊。

RESOLUTION

Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:

322756How to back up and restore the registry in Windows

To resolve this problem, add the GpNetworkStartTimeoutPolicyValue registry entry on the Windows XP SP2-based computer. This entry specifies the number of seconds that the system waits before it tries to run the Group Policy startup script again. To find the value that will work for your configuration, define a decimal value of 60, and then incrementally increase this value until the problem is resolved.
To add the GpNetworkStartTimeoutPolicyValue registry entry and to define the value, follow these steps:

1.Click Start, click Run, type regedit, and then click OK.

2.Expand the following registry subkey:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

3.Right-click Winlogon, point to New, and then click DWORD Value.

4.To name the new entry, type GpNetworkStartTimeoutPolicyValue, and then press ENTER.

5.Right-click GpNetworkStartTimeoutPolicyValue, and then click Modify.

6.Under Base, click Decimal.

7.In the Value data box, type 60, and then click OK.

8.Close Registry Editor, and then restart the computer.

9.If the Group Policy startup script does not run, incrementally increase the value of the GpNetworkStartTimeoutPolicyValue registry entry until the problem is resolved.

參考資料

Group Policy may not install the PolicyMaker Software Update client on a Windows XP Service Pack 2-based computer, and event ID 5719 and event ID 1054 are logged"

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

案例四 外點XP cannot apply Group Policy

總公司 ServerFrame

     |   雙向 4M

   ISP

     |     2M/512k

分公司 ClientFrame
根據封包及Userenv 及GPresult 確認.此Client Frame 主要為 Slowlink 連線. 故會有很多GPO 套用不會生效.

Gpresult:

下面的RSOP是收集於分公司的client電腦。

RSOP data for msft\00193 on SA100193-XPPC : Logging Mode
------------------------------------------------------------

OS Type:                     Microsoft Windows XP Professional
OS Configuration:            Member Workstation
OS Version:                  5.1.2600
Terminal Server Mode:        Remote Administration
Site Name:                   Default-First-Site-Name
Roaming Profile:            
Local Profile:               C:\Documents and Settings\00193
Connected over a slow link?: Yes

下面的RSOP是收集於總公司的client電腦。

RSOP data for msft\00840 on MIS00840-XPNB : Logging Mode
------------------------------------------------------------

OS Type:                     Microsoft Windows XP Professional
OS Configuration:            Member Workstation
OS Version:                  5.1.2600
Terminal Server Mode:        Remote Administration
Site Name:                   Default-First-Site-Name
Roaming Profile:            
Local Profile:               C:\Documents and Settings\00840
Connected over a slow link?: No

經過判斷,電腦認為這個網路連線是屬於低速連線,我們可以嘗試關閉 Client PC SlowLink 偵測:

To disable slow link detection on the Windows XP client computer, set the following registry values:

Registry subkey: HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\System
Value name: GroupPolicyMinTransferRate
Value type: DWORD
Value Data: 0

Registry subkey: HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System
Value name: GroupPolicyMinTransferRate Value type: DWORD
Value Data: 0

These registry settings must be configured manually because Group Policy is not applied in this scenario.

These registry settings are otherwise set by the following Group Policy settings:

Policy location: Computer Configuration\Administrative Templates\System\Group Policy
Policy name: Group Policy slow link detection
Policy setting: Enabled with a value of 0

Policy location: User Configuration\Administrative Templates\System\Group Policy
Policy name: Group Policy slow link detection
Policy setting: Enabled with a value of 0

額外的建議:

1.網路專線(wan)加大

2.外點當地擺放DC

3.Disable slow link detection(預設都有開啟)

Reference:

Default Behavior for Group Policy Extensions with Slow Link 227369
How a slow link is detected for processing user profiles and Group Policy 227260