Skip to content

Commit 78b646b

Browse files
authored
Adds support for system account lookup (#478)
1 parent 6e76ad9 commit 78b646b

File tree

1 file changed

+6
-2
lines changed
  • contrib/win32/win32compat

1 file changed

+6
-2
lines changed

contrib/win32/win32compat/pwd.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,13 @@ get_passwd(const wchar_t * user_utf16, PSID sid)
252252
goto cleanup;
253253
}
254254

255-
/* If standard local user name, just use name without decoration */
256-
if ((_wcsicmp(domain_name, computer_name) == 0) && (_wcsicmp(computer_name, user_name) != 0))
255+
/* if standard local user name or system account, just use name without decoration */
256+
const SID_IDENTIFIER_AUTHORITY nt_authority = SECURITY_NT_AUTHORITY;
257+
if (((_wcsicmp(domain_name, computer_name) == 0) && (_wcsicmp(computer_name, user_name) != 0)) ||
258+
((memcmp(&nt_authority, GetSidIdentifierAuthority((PSID)binary_sid), sizeof(SID_IDENTIFIER_AUTHORITY)) == 0) &&
259+
(((SID*)binary_sid)->SubAuthority[0] == SECURITY_LOCAL_SYSTEM_RID))) {
257260
wcscpy_s(user_resolved, ARRAYSIZE(user_resolved), user_name);
261+
}
258262

259263
/* put any other format in sam compatible format */
260264
else

0 commit comments

Comments
 (0)