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.

138 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 1995-2001 Microsoft Corporation
  3. Module Name:
  4. rpcbind.c
  5. Abstract:
  6. This module contains the RPC bind and un-bind routines for the
  7. Configuration Manager client-side APIs.
  8. Author:
  9. Paula Tomlinson (paulat) 6-21-1995
  10. Environment:
  11. User-mode only.
  12. Revision History:
  13. 21-June-1995 paulat
  14. Creation and initial implementation.
  15. --*/
  16. //
  17. // includes
  18. //
  19. #include "precomp.h"
  20. #include "cfgi.h"
  21. handle_t
  22. PNP_HANDLE_bind (
  23. PNP_HANDLE ServerName
  24. )
  25. /*++
  26. Routine Description:
  27. This routine calls a common bind routine that is shared by all
  28. services. This routine is called from the PNP API client stubs
  29. when it is necessary to bind to a server. The binding is done to
  30. allow impersonation by the server since that is necessary for the
  31. API calls.
  32. Arguments:
  33. ServerName - A pointer to a string containing the name of the server
  34. to bind with.
  35. Return Value:
  36. The binding handle is returned to the stub routine. If the
  37. binding is unsuccessful, a NULL will be returned.
  38. --*/
  39. {
  40. handle_t BindingHandle;
  41. RPC_STATUS Status;
  42. Status = RpcpBindRpc(
  43. ServerName, // UNC Server Name
  44. L"ntsvcs",
  45. L"Security=Impersonation Dynamic True",
  46. &BindingHandle);
  47. //
  48. // the possible return codes from RpcpBindRpc are STATUS_SUCCESS,
  49. // STATUS_NO_MEMORY and STATUS_INVALID_COMPUTER_NAME. Since the format
  50. // of the bind routine is fixed, set any errors encountered as the last
  51. // error and return NULL.
  52. //
  53. if (Status != STATUS_SUCCESS) {
  54. BindingHandle = NULL;
  55. if (Status == STATUS_NO_MEMORY) {
  56. SetLastError(ERROR_NOT_ENOUGH_MEMORY);
  57. }
  58. else if (Status == STATUS_INVALID_COMPUTER_NAME) {
  59. SetLastError(ERROR_INVALID_COMPUTERNAME);
  60. }
  61. else SetLastError(ERROR_GEN_FAILURE);
  62. }
  63. return BindingHandle;
  64. } // PNP_HANDLE_bind
  65. void
  66. PNP_HANDLE_unbind (
  67. PNP_HANDLE ServerName,
  68. handle_t BindingHandle
  69. )
  70. /*++
  71. Routine Description:
  72. This routine calls a common unbind routine that is shared by
  73. all services. It is called from the Browser service client stubs
  74. when it is necessary to unbind from the server end.
  75. Arguments:
  76. ServerName - This is the name of the server from which to unbind.
  77. BindingHandle - This is the binding handle that is to be closed.
  78. Return Value:
  79. none.
  80. --*/
  81. {
  82. RPC_STATUS status;
  83. UNREFERENCED_PARAMETER(ServerName);
  84. status = RpcpUnbindRpc(BindingHandle);
  85. return;
  86. } // PNP_HANDLE_unbind