windows-nt/Source/XPSP1/NT/ds/security/services/scerpc/client/clntutil.cpp
2020-09-26 16:20:57 +08:00

171 lines
3.3 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*++
Copyright (c) 1996 Microsoft Corporation
Module Name:
common.cpp
Abstract:
Shared APIs
Author:
Jin Huang
Revision History:
jinhuang 23-Jan-1998 merged from multiple modules
--*/
#include "headers.h"
#include <ntrpcp.h>
#include "clntutil.h"
#include <ntlsa.h>
PVOID theCallBack = NULL;
HANDLE hCallbackWnd=NULL;
DWORD CallbackType = 0;
#define g_ServiceName L"scesrv"
SCESTATUS
ScepSetCallback(
IN PVOID pCallback OPTIONAL,
IN HANDLE hWnd OPTIONAL,
IN DWORD Type
)
{
theCallBack = pCallback;
hCallbackWnd = hWnd;
CallbackType = Type;
return(SCESTATUS_SUCCESS);
}
NTSTATUS
ScepBindSecureRpc(
IN LPWSTR servername,
IN LPWSTR servicename,
IN LPWSTR networkoptions,
OUT RPC_BINDING_HANDLE * pBindingHandle
)
/*
Routine Description:
This routine binds to the servicename on the server. A binding handle is
returned if successful.
If the service on the server is not available, this client will try to
start that service then bind to it.
Arguments:
servername - the system name where SCE server service is running on
servicename - the pipe (port) name of SCE server
networkoptions - the network protocol options
pBindingHandle - the binding handle to output
Return Value:
NTSTATUS
*/
{
if ( !servicename || !pBindingHandle ) {
return(STATUS_INVALID_PARAMETER);
}
//
// activate the server (if already started, just return)
//
NTSTATUS NtStatus = RpcpBindRpc(
servername,
servicename,
networkoptions,
pBindingHandle
);
if ( NT_SUCCESS(NtStatus) && *pBindingHandle ){
//
// set authentication info to use secure RPC
// if can't set authentication, ignore the error
//
(VOID) RpcBindingSetAuthInfo(
*pBindingHandle,
NULL,
RPC_C_AUTHN_LEVEL_DEFAULT,
RPC_C_AUTHN_WINNT,
NULL,
RPC_C_AUTHZ_DCE
);
}
return(NtStatus);
}
NTSTATUS
ScepBindRpc(
IN LPWSTR servername,
IN LPWSTR servicename,
IN LPWSTR networkoptions,
OUT RPC_BINDING_HANDLE * pBindingHandle
)
/*
Routine Description:
This routine binds to the servicename on the server. A binding handle is
returned if successful.
If the service on the server is not available, this client will try to
start that service then bind to it.
Arguments:
servername - the system name where SCE server service is running on
servicename - the pipe (port) name of SCE server
networkoptions - the network protocol options
pBindingHandle - the binding handle to output
Return Value:
NTSTATUS
*/
{
if ( !servicename || !pBindingHandle ) {
return(STATUS_INVALID_PARAMETER);
}
//
// activate the server (if already started, just return)
//
return( RpcpBindRpc(
servername,
servicename,
networkoptions,
pBindingHandle
) );
}