Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

170 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. common.cpp
  5. Abstract:
  6. Shared APIs
  7. Author:
  8. Jin Huang
  9. Revision History:
  10. jinhuang 23-Jan-1998 merged from multiple modules
  11. --*/
  12. #include "headers.h"
  13. #include <ntrpcp.h>
  14. #include "clntutil.h"
  15. #include <ntlsa.h>
  16. PVOID theCallBack = NULL;
  17. HANDLE hCallbackWnd=NULL;
  18. DWORD CallbackType = 0;
  19. #define g_ServiceName L"scesrv"
  20. SCESTATUS
  21. ScepSetCallback(
  22. IN PVOID pCallback OPTIONAL,
  23. IN HANDLE hWnd OPTIONAL,
  24. IN DWORD Type
  25. )
  26. {
  27. theCallBack = pCallback;
  28. hCallbackWnd = hWnd;
  29. CallbackType = Type;
  30. return(SCESTATUS_SUCCESS);
  31. }
  32. NTSTATUS
  33. ScepBindSecureRpc(
  34. IN LPWSTR servername,
  35. IN LPWSTR servicename,
  36. IN LPWSTR networkoptions,
  37. OUT RPC_BINDING_HANDLE * pBindingHandle
  38. )
  39. /*
  40. Routine Description:
  41. This routine binds to the servicename on the server. A binding handle is
  42. returned if successful.
  43. If the service on the server is not available, this client will try to
  44. start that service then bind to it.
  45. Arguments:
  46. servername - the system name where SCE server service is running on
  47. servicename - the pipe (port) name of SCE server
  48. networkoptions - the network protocol options
  49. pBindingHandle - the binding handle to output
  50. Return Value:
  51. NTSTATUS
  52. */
  53. {
  54. if ( !servicename || !pBindingHandle ) {
  55. return(STATUS_INVALID_PARAMETER);
  56. }
  57. //
  58. // activate the server (if already started, just return)
  59. //
  60. NTSTATUS NtStatus = RpcpBindRpc(
  61. servername,
  62. servicename,
  63. networkoptions,
  64. pBindingHandle
  65. );
  66. if ( NT_SUCCESS(NtStatus) && *pBindingHandle ){
  67. //
  68. // set authentication info to use secure RPC
  69. // if can't set authentication, ignore the error
  70. //
  71. (VOID) RpcBindingSetAuthInfo(
  72. *pBindingHandle,
  73. NULL,
  74. RPC_C_AUTHN_LEVEL_DEFAULT,
  75. RPC_C_AUTHN_WINNT,
  76. NULL,
  77. RPC_C_AUTHZ_DCE
  78. );
  79. }
  80. return(NtStatus);
  81. }
  82. NTSTATUS
  83. ScepBindRpc(
  84. IN LPWSTR servername,
  85. IN LPWSTR servicename,
  86. IN LPWSTR networkoptions,
  87. OUT RPC_BINDING_HANDLE * pBindingHandle
  88. )
  89. /*
  90. Routine Description:
  91. This routine binds to the servicename on the server. A binding handle is
  92. returned if successful.
  93. If the service on the server is not available, this client will try to
  94. start that service then bind to it.
  95. Arguments:
  96. servername - the system name where SCE server service is running on
  97. servicename - the pipe (port) name of SCE server
  98. networkoptions - the network protocol options
  99. pBindingHandle - the binding handle to output
  100. Return Value:
  101. NTSTATUS
  102. */
  103. {
  104. if ( !servicename || !pBindingHandle ) {
  105. return(STATUS_INVALID_PARAMETER);
  106. }
  107. //
  108. // activate the server (if already started, just return)
  109. //
  110. return( RpcpBindRpc(
  111. servername,
  112. servicename,
  113. networkoptions,
  114. pBindingHandle
  115. ) );
  116. }