{"record":{"id":"4653dda262667d43","repo":"ansible/ansible","slug":"allocatelocallyuniqueid-failed","errorCode":null,"errorMessage":"AllocateLocallyUniqueId() failed","messagePattern":"AllocateLocallyUniqueId\\(\\) failed","errorType":"exception","errorClass":"Win32Exception","httpStatus":null,"severity":"error","filePath":"lib/ansible/module_utils/csharp/Ansible.Become.cs","lineNumber":573,"sourceCode":"                        {\n                            Length = (UInt16)usernameLength,\n                            MaximumLength = (UInt16)usernameLength,\n                            Buffer = usernamePtr,\n                        },\n                        ClientRealm = new NativeHelpers.LSA_UNICODE_STRING\n                        {\n                            Length = (UInt16)domainLength,\n                            MaximumLength = (UInt16)domainLength,\n                            Buffer = domainPtr,\n                        },\n                    };\n                    Marshal.StructureToPtr(s4uLogon, authInfo, false);\n                    Marshal.Copy(username.ToCharArray(), 0, usernamePtr, username.Length);\n                    Marshal.Copy(domainName.ToCharArray(), 0, domainPtr, domainName.Length);\n\n                    Luid sourceLuid;\n                    if (!NativeMethods.AllocateLocallyUniqueId(out sourceLuid))\n                        throw new Process.Win32Exception(\"AllocateLocallyUniqueId() failed\");\n\n                    NativeHelpers.TOKEN_SOURCE tokenSource = new NativeHelpers.TOKEN_SOURCE\n                    {\n                        SourceName = \"ansible\\0\".ToCharArray(),\n                        SourceIdentifier = sourceLuid,\n                    };\n\n                    // Only Batch or Network will work with S4U, prefer Batch but use Network if asked\n                    LogonType lsaLogonType = logonType == LogonType.Network\n                        ? LogonType.Network\n                        : LogonType.Batch;\n                    SafeLsaMemoryBuffer profileBuffer;\n                    UInt32 profileBufferLength;\n                    Luid logonId;\n                    SafeNativeHandle hToken;\n                    IntPtr quotas;\n                    UInt32 subStatus;\n","sourceCodeStart":555,"sourceCodeEnd":591,"githubUrl":"https://github.com/ansible/ansible/blob/9cf16a4aca7898481c257f1e17ad28d0b67b1f85/lib/ansible/module_utils/csharp/Ansible.Become.cs#L555-L591","documentation":"AllocateLocallyUniqueId is a near-infallible Win32 helper that allocates a LUID for the TOKEN_SOURCE structure used in LsaLogonUser; it only fails on extreme conditions (kernel memory exhaustion / handle-table trouble). Its failure aborts the S4U logon before it starts.","triggerScenarios":"Genuine kernel resource exhaustion at the moment the S4U logon path builds its TOKEN_SOURCE; practically never seen in normal operation.","commonSituations":"Severely memory-pressure-exhausted Windows hosts; recurring appearances indicate deeper OS instability rather than an Ansible configuration problem.","solutions":["Retry the task — transient allocation failures usually clear","If persistent, free resources / investigate system memory and kernel pool usage on the target host"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (Win32Exception e) when (e.Message.Contains(\"AllocateLocallyUniqueId\"))\n{ // transient resource exhaustion: retry after delay\n}","preventionTips":["Recurrence signals OS-level resource exhaustion — investigate rather than retry indefinitely"],"tags":["csharp","windows","become","win32","resource-exhaustion"],"backgroundTag":null,"analyzedSha":"9cf16a4aca7898481c257f1e17ad28d0b67b1f85","analyzedAt":"2026-08-15T00:15:47.100Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}