📄 nlmain.c
字号:
NlpInitClientBuffer( &ClientBufferDesc, ClientRequest );
UNREFERENCED_PARAMETER( ClientBufferBase );
if ( SubmitBufferSize < sizeof(MSV1_0_ENUMUSERS_REQUEST) ) {
Status = STATUS_INVALID_PARAMETER;
goto Cleanup;
}
EnumRequest = (PMSV1_0_ENUMUSERS_REQUEST) ProtocolSubmitBuffer;
ASSERT( EnumRequest->MessageType == MsV1_0EnumerateUsers );
//
// Count the current number of active logons
//
NlpLockActiveLogons();
ActiveLogonsAreLocked = TRUE;
for( Logon = NlpActiveLogons; Logon != NULL; Logon = Logon->Next ) {
LogonCount ++;
}
//
// Allocate a buffer to return to the caller.
//
*ReturnBufferSize = sizeof(MSV1_0_ENUMUSERS_RESPONSE) +
LogonCount * (sizeof(LUID) + sizeof(ULONG));
Status = NlpAllocateClientBuffer( &ClientBufferDesc,
sizeof(MSV1_0_ENUMUSERS_RESPONSE),
*ReturnBufferSize );
if ( !NT_SUCCESS( Status ) ) {
goto Cleanup;
}
EnumResponse = (PMSV1_0_ENUMUSERS_RESPONSE) ClientBufferDesc.MsvBuffer;
//
// Fill in the return buffer.
//
EnumResponse->MessageType = MsV1_0EnumerateUsers;
EnumResponse->NumberOfLoggedOnUsers = LogonCount;
Where = (PUCHAR)(EnumResponse + 1);
//
// Loop through the Active Logon Table copying the LogonId of each session.
//
EnumResponse->LogonIds = (PLUID)(ClientBufferDesc.UserBuffer +
(Where - ClientBufferDesc.MsvBuffer));
for( Logon = NlpActiveLogons; Logon != NULL; Logon = Logon->Next ) {
*((PLUID)Where) = Logon->LogonId,
Where += sizeof(LUID);
}
//
// Loop through the Active Logon Table copying the EnumHandle of
// each session.
//
EnumResponse->EnumHandles = (PULONG)(ClientBufferDesc.UserBuffer +
(Where - ClientBufferDesc.MsvBuffer));
for( Logon = NlpActiveLogons; Logon != NULL; Logon = Logon->Next ) {
*((PULONG)Where) = Logon->EnumHandle,
Where += sizeof(ULONG);
}
//
// Flush the buffer to the client's address space.
//
Status = NlpFlushClientBuffer( &ClientBufferDesc,
ProtocolReturnBuffer );
Cleanup:
//
// Be sure to unlock the lock on the Active logon list.
//
if ( ActiveLogonsAreLocked ) {
NlpUnlockActiveLogons();
}
//
// If we weren't successful, free the buffer in the clients address space.
//
if ( !NT_SUCCESS(Status)) {
NlpFreeClientBuffer( &ClientBufferDesc );
}
//
// Return status to the caller.
//
*ProtocolStatus = Status;
return STATUS_SUCCESS;
}
NTSTATUS
MspLm20GetUserInfo (
IN PLSA_CLIENT_REQUEST ClientRequest,
IN PVOID ProtocolSubmitBuffer,
IN PVOID ClientBufferBase,
IN ULONG SubmitBufferSize,
OUT PVOID *ProtocolReturnBuffer,
OUT PULONG ReturnBufferSize,
OUT PNTSTATUS ProtocolStatus
)
/*++
Routine Description:
This routine is the dispatch routine for LsaCallAuthenticationPackage()
with a message type of MsV1_0GetUserInfo. This routine
returns information describing a particular Logon Id.
Arguments:
The arguments to this routine are identical to those of LsaApCallPackage.
Only the special attributes of these parameters as they apply to
this routine are mentioned here.
Return Value:
STATUS_SUCCESS - Indicates the service completed successfully.
STATUS_QUOTA_EXCEEDED - This error indicates that the logon
could not be completed because the client does not have
sufficient quota to allocate the return buffer.
--*/
{
NTSTATUS Status;
PMSV1_0_GETUSERINFO_REQUEST GetInfoRequest;
PMSV1_0_GETUSERINFO_RESPONSE GetInfoResponse = NULL;
CLIENT_BUFFER_DESC ClientBufferDesc;
BOOLEAN ActiveLogonsAreLocked = FALSE;
PACTIVE_LOGON *ActiveLogon;
PACTIVE_LOGON Logon;
ULONG SidLength;
//
// Ensure the specified Submit Buffer is of reasonable size and
// relocate all of the pointers to be relative to the LSA allocated
// buffer.
//
NlpInitClientBuffer( &ClientBufferDesc, ClientRequest );
UNREFERENCED_PARAMETER( ClientBufferBase );
if ( SubmitBufferSize < sizeof(MSV1_0_GETUSERINFO_REQUEST) ) {
Status = STATUS_INVALID_PARAMETER;
goto Cleanup;
}
GetInfoRequest = (PMSV1_0_GETUSERINFO_REQUEST) ProtocolSubmitBuffer;
ASSERT( GetInfoRequest->MessageType == MsV1_0GetUserInfo );
//
// Find the Active logon entry for this particular Logon Id.
//
NlpLockActiveLogons();
ActiveLogonsAreLocked = TRUE;
if (!NlpFindActiveLogon( &GetInfoRequest->LogonId, &ActiveLogon )){
Status = STATUS_NO_SUCH_LOGON_SESSION;
goto Cleanup;
}
Logon = *ActiveLogon;
//
// Allocate a buffer to return to the caller.
//
SidLength = RtlLengthSid( Logon->UserSid );
*ReturnBufferSize = sizeof(MSV1_0_GETUSERINFO_RESPONSE) +
Logon->UserName.Length + sizeof(WCHAR) +
Logon->LogonDomainName.Length + sizeof(WCHAR) +
Logon->LogonServer.Length + sizeof(WCHAR) +
SidLength;
Status = NlpAllocateClientBuffer( &ClientBufferDesc,
sizeof(MSV1_0_GETUSERINFO_RESPONSE),
*ReturnBufferSize );
if ( !NT_SUCCESS( Status ) ) {
goto Cleanup;
}
GetInfoResponse = (PMSV1_0_GETUSERINFO_RESPONSE) ClientBufferDesc.MsvBuffer;
//
// Fill in the return buffer.
//
GetInfoResponse->MessageType = MsV1_0GetUserInfo;
GetInfoResponse->LogonType = Logon->LogonType;
//
// Copy ULONG aligned data first
//
GetInfoResponse->UserSid = ClientBufferDesc.UserBuffer +
ClientBufferDesc.StringOffset;
RtlCopyMemory( ClientBufferDesc.MsvBuffer + ClientBufferDesc.StringOffset,
Logon->UserSid,
SidLength );
ClientBufferDesc.StringOffset += SidLength;
//
// Copy WCHAR aligned data
//
NlpPutClientString( &ClientBufferDesc,
&GetInfoResponse->UserName,
&Logon->UserName );
NlpPutClientString( &ClientBufferDesc,
&GetInfoResponse->LogonDomainName,
&Logon->LogonDomainName );
NlpPutClientString( &ClientBufferDesc,
&GetInfoResponse->LogonServer,
&Logon->LogonServer );
//
// Flush the buffer to the client's address space.
//
Status = NlpFlushClientBuffer( &ClientBufferDesc,
ProtocolReturnBuffer );
Cleanup:
//
// Be sure to unlock the lock on the Active logon list.
//
if ( ActiveLogonsAreLocked ) {
NlpUnlockActiveLogons();
}
//
// If we weren't successful, free the buffer in the clients address space.
//
if ( !NT_SUCCESS(Status)) {
NlpFreeClientBuffer( &ClientBufferDesc );
}
//
// Return status to the caller.
//
*ProtocolStatus = Status;
return STATUS_SUCCESS;
}
NTSTATUS
MspLm20ReLogonUsers (
IN PLSA_CLIENT_REQUEST ClientRequest,
IN PVOID ProtocolSubmitBuffer,
IN PVOID ClientBufferBase,
IN ULONG SubmitBufferSize,
OUT PVOID *ProtocolReturnBuffer,
OUT PULONG ReturnBufferSize,
OUT PNTSTATUS ProtocolStatus
)
/*++
Routine Description:
This routine is the dispatch routine for LsaCallAuthenticationPackage()
with a message type of MsV1_0RelogonUsers. For each logon session
which was validated by the specified domain controller, the logon session
is re-established with that same domain controller.
Arguments:
The arguments to this routine are identical to those of LsaApCallPackage.
Only the special attributes of these parameters as they apply to
this routine are mentioned here.
Return Value:
STATUS_SUCCESS - Indicates the service completed successfully.
--*/
{
UNREFERENCED_PARAMETER( ClientRequest );
UNREFERENCED_PARAMETER( ProtocolSubmitBuffer);
UNREFERENCED_PARAMETER( ClientBufferBase);
UNREFERENCED_PARAMETER( SubmitBufferSize);
UNREFERENCED_PARAMETER( ReturnBufferSize);
*ProtocolReturnBuffer = NULL;
*ProtocolStatus = STATUS_NOT_IMPLEMENTED;
return STATUS_SUCCESS;
}
NTSTATUS
MspLm20GenericPassthrough (
IN PLSA_CLIENT_REQUEST ClientRequest,
IN PVOID ProtocolSubmitBuffer,
IN PVOID ClientBufferBase,
IN ULONG SubmitBufferSize,
OUT PVOID *ProtocolReturnBuffer,
OUT PULONG ReturnBufferSize,
OUT PNTSTATUS ProtocolStatus
)
/*++
Routine Description:
This routine is the dispatch routine for LsaCallAuthenticationPackage()
with a message type of MsV1_0Lm20GenericPassthrough. It is called by
a client wishing to make a CallAuthenticationPackage call against
a domain controller.
Arguments:
The arguments to this routine are identical to those of LsaApCallPackage.
Only the special attributes of these parameters as they apply to
this routine are mentioned here.
Return Value:
STATUS_SUCCESS - Indicates the service completed successfully.
STATUS_QUOTA_EXCEEDED - This error indicates that the logon
could not be completed because the client does not have
sufficient quota to allocate the return buffer.
--*/
{
NTSTATUS Status = STATUS_SUCCESS;
PMSV1_0_PASSTHROUGH_REQUEST PassthroughRequest;
PMSV1_0_PASSTHROUGH_RESPONSE PassthroughResponse;
CLIENT_BUFFER_DESC ClientBufferDesc;
BOOLEAN Authoritative;
PNETLOGON_VALIDATION_GENERIC_INFO ValidationGeneric = NULL;
NETLOGON_GENERIC_INFO LogonGeneric;
PNETLOGON_LOGON_IDENTITY_INFO LogonInformation;
NlpInitClientBuffer( &ClientBufferDesc, ClientRequest );
*ProtocolStatus = STATUS_SUCCESS;
//
// Ensure the specified Submit Buffer is of reasonable size and
// relocate all of the pointers to be relative to the LSA allocated
// buffer.
//
if ( SubmitBufferSize < sizeof(MSV1_0_PASSTHROUGH_REQUEST) ) {
Status = STATUS_INVALID_PARAMETER;
goto Cleanup;
}
PassthroughRequest = (PMSV1_0_PASSTHROUGH_REQUEST) ProtocolSubmitBuffer;
RELOCATE_ONE( &PassthroughRequest->DomainName );
RELOCATE_ONE( &PassthroughRequest->PackageName );
//
// Make sure the buffer fits in the supplied size
//
if (PassthroughRequest->LogonData != NULL) {
if (PassthroughRequest->LogonData + PassthroughRequest->DataLength <
PassthroughRequest->LogonData ) {
Status = STATUS_INVALID_PARAMETER;
goto Cleanup;
}
if ((ULONG_PTR)ClientBufferBase + SubmitBufferSize < (ULONG_PTR)ClientBufferBase ) {
Status = STATUS_INVALID_PARAMETER;
goto Cleanup;
}
if (PassthroughRequest->LogonData + PassthroughRequest->DataLength >
(PUCHAR) ClientBufferBase + SubmitBufferSize) {
Status = STATUS_INVALID_PARAMETER;
goto Cleanup;
}
//
// Reset the pointers for the validation data
//
PassthroughRequest->LogonData =
(PUCHAR) PassthroughRequest -
(ULONG_PTR) ClientBufferBase +
(ULONG_PTR) PassthroughRequest->LogonData;
}
//
// Build the structure to pass to Netlogon
//
RtlZeroMemory(
&LogonGeneric,
sizeof(LogonGeneric)
);
LogonGeneric.Identity.LogonDomainName = PassthroughRequest->DomainName;
LogonGeneric.PackageName = PassthroughRequest->PackageName;
LogonGeneric.LogonData = PassthroughRequest->LogonData;
LogonGeneric.DataLength = PassthroughRequest->DataLength;
LogonInformation =
(PNETLOGON_LOGON_IDENTITY_INFO) &LogonGeneric;
//
// Call Netlogon to remote the request
//
//
// Wait for NETLOGON to finish initialization.
//
if ( !NlpNetlogonIn
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -