netapi32: NetUserModalsGet bug fixes and cleanup.

This commit is contained in:
Robert Reif 2006-08-12 18:49:37 -04:00 committed by Alexandre Julliard
parent ef1c8fd118
commit d54043c028
1 changed files with 15 additions and 13 deletions

View File

@ -618,10 +618,11 @@ NET_API_STATUS WINAPI NetUserModalsGet(
NTSTATUS ntStatus; NTSTATUS ntStatus;
PSID domainIdentifier = NULL; PSID domainIdentifier = NULL;
int domainNameLen; int domainNameLen;
ZeroMemory(&objectAttributes, sizeof(objectAttributes)); ZeroMemory(&objectAttributes, sizeof(objectAttributes));
objectAttributes.Length = sizeof(objectAttributes);
ntStatus = LsaOpenPolicy(NULL, &objectAttributes,
ntStatus = LsaOpenPolicy(NULL, &objectAttributes,
POLICY_VIEW_LOCAL_INFORMATION, POLICY_VIEW_LOCAL_INFORMATION,
&policyHandle); &policyHandle);
if (ntStatus != STATUS_SUCCESS) if (ntStatus != STATUS_SUCCESS)
@ -630,28 +631,29 @@ NET_API_STATUS WINAPI NetUserModalsGet(
LsaNtStatusToWinError(ntStatus)); LsaNtStatusToWinError(ntStatus));
return ntStatus; return ntStatus;
} }
ntStatus = LsaQueryInformationPolicy(policyHandle, ntStatus = LsaQueryInformationPolicy(policyHandle,
PolicyAccountDomainInformation, PolicyAccountDomainInformation,
(PVOID *)&domainInfo); (PVOID *)&domainInfo);
if (ntStatus != STATUS_SUCCESS) if (ntStatus != STATUS_SUCCESS)
{ {
WARN("LsaQueryInformationPolicy failed with NT status %lx\n", WARN("LsaQueryInformationPolicy failed with NT status %lx\n",
LsaNtStatusToWinError(ntStatus)); LsaNtStatusToWinError(ntStatus));
LsaClose(policyHandle);
return ntStatus; return ntStatus;
} }
domainIdentifier = domainInfo->DomainSid; domainIdentifier = domainInfo->DomainSid;
domainNameLen = lstrlenW(domainInfo->DomainName.Buffer) + 1; domainNameLen = lstrlenW(domainInfo->DomainName.Buffer) + 1;
LsaClose(policyHandle); LsaClose(policyHandle);
ntStatus = NetApiBufferAllocate(sizeof(USER_MODALS_INFO_2) + ntStatus = NetApiBufferAllocate(sizeof(USER_MODALS_INFO_2) +
GetLengthSid(domainIdentifier) + GetLengthSid(domainIdentifier) +
domainNameLen * sizeof(WCHAR), domainNameLen * sizeof(WCHAR),
(LPVOID *)pbuffer); (LPVOID *)pbuffer);
if (ntStatus != NERR_Success) if (ntStatus != NERR_Success)
{ {
WARN("NetApiBufferAllocate() failed\n"); WARN("NetApiBufferAllocate() failed\n");
LsaFreeMemory(domainInfo); LsaFreeMemory(domainInfo);
return ntStatus; return ntStatus;
@ -662,7 +664,7 @@ NET_API_STATUS WINAPI NetUserModalsGet(
sizeof(USER_MODALS_INFO_2)); sizeof(USER_MODALS_INFO_2));
umi->usrmod2_domain_name = (LPWSTR)(*pbuffer + umi->usrmod2_domain_name = (LPWSTR)(*pbuffer +
sizeof(USER_MODALS_INFO_2) + GetLengthSid(domainIdentifier)); sizeof(USER_MODALS_INFO_2) + GetLengthSid(domainIdentifier));
lstrcpynW(umi->usrmod2_domain_name, lstrcpynW(umi->usrmod2_domain_name,
domainInfo->DomainName.Buffer, domainInfo->DomainName.Buffer,
domainNameLen); domainNameLen);
@ -670,9 +672,9 @@ NET_API_STATUS WINAPI NetUserModalsGet(
domainIdentifier); domainIdentifier);
LsaFreeMemory(domainInfo); LsaFreeMemory(domainInfo);
break; break;
} }
case 3: case 3:
/* return lockout information */ /* return lockout information */
FIXME("level 3 not implemented!\n"); FIXME("level 3 not implemented!\n");
@ -683,6 +685,6 @@ NET_API_STATUS WINAPI NetUserModalsGet(
*pbuffer = NULL; *pbuffer = NULL;
return ERROR_INVALID_LEVEL; return ERROR_INVALID_LEVEL;
} }
return NERR_Success; return NERR_Success;
} }