Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
fc5ea773
Commit
fc5ea773
authored
Feb 04, 2009
by
Juan Lang
Committed by
Alexandre Julliard
Feb 05, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32: Support the computer name as an account name in LookupAccountNameW.
parent
0b32bdc4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
118 additions
and
62 deletions
+118
-62
security.c
dlls/advapi32/security.c
+118
-61
security.c
dlls/advapi32/tests/security.c
+0
-1
No files found.
dlls/advapi32/security.c
View file @
fc5ea773
...
...
@@ -2531,17 +2531,119 @@ LookupAccountNameA(
}
/******************************************************************************
* lookup_user_account_name
*/
static
BOOL
lookup_user_account_name
(
PSID
Sid
,
PDWORD
cbSid
,
LPWSTR
ReferencedDomainName
,
LPDWORD
cchReferencedDomainName
,
PSID_NAME_USE
peUse
)
{
/* Default implementation: Always return a default SID */
SID_IDENTIFIER_AUTHORITY
identifierAuthority
=
{
SECURITY_NT_AUTHORITY
};
BOOL
ret
;
PSID
pSid
;
static
const
WCHAR
dm
[]
=
{
'D'
,
'O'
,
'M'
,
'A'
,
'I'
,
'N'
,
0
};
DWORD
nameLen
;
LPCWSTR
domainName
;
ret
=
AllocateAndInitializeSid
(
&
identifierAuthority
,
2
,
SECURITY_BUILTIN_DOMAIN_RID
,
DOMAIN_ALIAS_RID_ADMINS
,
0
,
0
,
0
,
0
,
0
,
0
,
&
pSid
);
if
(
!
ret
)
return
FALSE
;
if
(
!
RtlValidSid
(
pSid
))
{
FreeSid
(
pSid
);
return
FALSE
;
}
if
(
Sid
!=
NULL
&&
(
*
cbSid
>=
GetLengthSid
(
pSid
)))
CopySid
(
*
cbSid
,
Sid
,
pSid
);
if
(
*
cbSid
<
GetLengthSid
(
pSid
))
{
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
ret
=
FALSE
;
}
*
cbSid
=
GetLengthSid
(
pSid
);
domainName
=
dm
;
nameLen
=
strlenW
(
domainName
);
if
(
*
cchReferencedDomainName
<=
nameLen
||
!
ret
)
{
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
nameLen
+=
1
;
ret
=
FALSE
;
}
else
if
(
ReferencedDomainName
)
strcpyW
(
ReferencedDomainName
,
domainName
);
*
cchReferencedDomainName
=
nameLen
;
if
(
ret
)
*
peUse
=
SidTypeUser
;
FreeSid
(
pSid
);
return
ret
;
}
/******************************************************************************
* lookup_computer_account_name
*/
static
BOOL
lookup_computer_account_name
(
PSID
Sid
,
PDWORD
cbSid
,
LPWSTR
ReferencedDomainName
,
LPDWORD
cchReferencedDomainName
,
PSID_NAME_USE
peUse
)
{
MAX_SID
local
;
BOOL
ret
;
static
const
WCHAR
dm
[]
=
{
'D'
,
'O'
,
'M'
,
'A'
,
'I'
,
'N'
,
0
};
DWORD
nameLen
;
LPCWSTR
domainName
;
if
((
ret
=
ADVAPI_GetComputerSid
(
&
local
)))
{
if
(
Sid
!=
NULL
&&
(
*
cbSid
>=
GetLengthSid
(
&
local
)))
CopySid
(
*
cbSid
,
Sid
,
&
local
);
if
(
*
cbSid
<
GetLengthSid
(
&
local
))
{
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
ret
=
FALSE
;
}
*
cbSid
=
GetLengthSid
(
&
local
);
}
domainName
=
dm
;
nameLen
=
strlenW
(
domainName
);
if
(
*
cchReferencedDomainName
<=
nameLen
||
!
ret
)
{
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
nameLen
+=
1
;
ret
=
FALSE
;
}
else
if
(
ReferencedDomainName
)
strcpyW
(
ReferencedDomainName
,
domainName
);
*
cchReferencedDomainName
=
nameLen
;
if
(
ret
)
*
peUse
=
SidTypeDomain
;
return
ret
;
}
/******************************************************************************
* LookupAccountNameW [ADVAPI32.@]
*/
BOOL
WINAPI
LookupAccountNameW
(
LPCWSTR
lpSystemName
,
LPCWSTR
lpAccountName
,
PSID
Sid
,
LPDWORD
cbSid
,
LPWSTR
ReferencedDomainName
,
LPDWORD
cchReferencedDomainName
,
PSID_NAME_USE
peUse
)
{
/* Default implementation: Always return a default SID */
SID_IDENTIFIER_AUTHORITY
identifierAuthority
=
{
SECURITY_NT_AUTHORITY
};
BOOL
ret
;
PSID
pSid
;
static
const
WCHAR
dm
[]
=
{
'D'
,
'O'
,
'M'
,
'A'
,
'I'
,
'N'
,
0
};
unsigned
int
i
;
DWORD
nameLen
;
LPWSTR
userName
=
NULL
;
...
...
@@ -2621,69 +2723,24 @@ BOOL WINAPI LookupAccountNameW( LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSI
userName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
nameLen
);
ret
=
GetUserNameW
(
userName
,
&
nameLen
);
if
(
ret
&&
strcmpW
(
lpAccountName
,
userName
)
!=
0
)
if
(
GetUserNameW
(
userName
,
&
nameLen
)
&&
!
strcmpW
(
lpAccountName
,
userName
))
ret
=
lookup_user_account_name
(
Sid
,
cbSid
,
ReferencedDomainName
,
cchReferencedDomainName
,
peUse
);
else
{
SetLastError
(
ERROR_NONE_MAPPED
);
ret
=
FALSE
;
nameLen
=
UNLEN
+
1
;
if
(
GetComputerNameW
(
userName
,
&
nameLen
)
&&
!
strcmpW
(
lpAccountName
,
userName
))
ret
=
lookup_computer_account_name
(
Sid
,
cbSid
,
ReferencedDomainName
,
cchReferencedDomainName
,
peUse
);
else
{
SetLastError
(
ERROR_NONE_MAPPED
);
ret
=
FALSE
;
}
}
HeapFree
(
GetProcessHeap
(),
0
,
userName
);
if
(
!
ret
)
{
return
ret
;
}
ret
=
AllocateAndInitializeSid
(
&
identifierAuthority
,
2
,
SECURITY_BUILTIN_DOMAIN_RID
,
DOMAIN_ALIAS_RID_ADMINS
,
0
,
0
,
0
,
0
,
0
,
0
,
&
pSid
);
if
(
!
ret
)
return
FALSE
;
if
(
!
RtlValidSid
(
pSid
))
{
FreeSid
(
pSid
);
return
FALSE
;
}
if
(
Sid
!=
NULL
&&
(
*
cbSid
>=
GetLengthSid
(
pSid
)))
CopySid
(
*
cbSid
,
Sid
,
pSid
);
if
(
*
cbSid
<
GetLengthSid
(
pSid
))
{
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
ret
=
FALSE
;
}
*
cbSid
=
GetLengthSid
(
pSid
);
domainName
=
dm
;
nameLen
=
strlenW
(
domainName
);
if
(
*
cchReferencedDomainName
<=
nameLen
||
!
ret
)
{
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
nameLen
+=
1
;
ret
=
FALSE
;
}
else
if
(
ReferencedDomainName
)
{
strcpyW
(
ReferencedDomainName
,
domainName
);
}
*
cchReferencedDomainName
=
nameLen
;
if
(
ret
)
{
*
peUse
=
SidTypeUser
;
}
FreeSid
(
pSid
);
return
ret
;
}
...
...
dlls/advapi32/tests/security.c
View file @
fc5ea773
...
...
@@ -1883,7 +1883,6 @@ static void test_LookupAccountName(void)
sid_size
=
0
;
domain_size
=
0
;
ret
=
LookupAccountNameA
(
NULL
,
computer_name
,
NULL
,
&
sid_size
,
NULL
,
&
domain_size
,
&
sid_use
);
todo_wine
ok
(
!
ret
&&
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
||
broken
(
GetLastError
()
==
ERROR_TRUSTED_DOMAIN_FAILURE
)
||
broken
(
GetLastError
()
==
ERROR_TRUSTED_RELATIONSHIP_FAILURE
)),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment