Leaked source code of windows server 2003
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.

139 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. bind.c
  5. Abstract:
  6. Contains the RPC bind and un-bind routines
  7. Author:
  8. Dave Snipp (davesn) 01-Jun-1991
  9. Environment:
  10. User Mode -Win32
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. #include "client.h"
  16. LPWSTR InterfaceAddress = L"\\pipe\\spoolss";
  17. /* Security=[Impersonation | Identification | Anonymous] [Dynamic | Static] [True | False]
  18. * (where True | False corresponds to EffectiveOnly)
  19. */
  20. LPWSTR StringBindingOptions = L"Security=Impersonation Dynamic False";
  21. handle_t GlobalBindHandle;
  22. handle_t
  23. STRING_HANDLE_bind (
  24. STRING_HANDLE lpStr)
  25. /*++
  26. Routine Description:
  27. This routine calls a common bind routine that is shared by all services.
  28. This routine is called from the server service client stubs when
  29. it is necessary to bind to a server.
  30. Arguments:
  31. ServerName - A pointer to a string containing the name of the server
  32. to bind with.
  33. Return Value:
  34. The binding handle is returned to the stub routine. If the
  35. binding is unsuccessful, a NULL will be returned.
  36. --*/
  37. {
  38. RPC_STATUS RpcStatus;
  39. LPWSTR StringBinding;
  40. handle_t BindingHandle = NULL;
  41. WCHAR* pszServerPrincName = NULL;
  42. if( (RpcStatus = RpcStringBindingComposeW(0,
  43. L"ncalrpc",
  44. 0,
  45. L"spoolss",
  46. StringBindingOptions,
  47. &StringBinding)) == RPC_S_OK)
  48. {
  49. if( (RpcStatus = RpcBindingFromStringBindingW(StringBinding,
  50. &BindingHandle)) == RPC_S_OK)
  51. {
  52. RPC_SECURITY_QOS RpcSecQos;
  53. RpcSecQos.Version = RPC_C_SECURITY_QOS_VERSION_1;
  54. RpcSecQos.Capabilities = RPC_C_QOS_CAPABILITIES_MUTUAL_AUTH;
  55. RpcSecQos.IdentityTracking = RPC_C_QOS_IDENTITY_DYNAMIC;
  56. RpcSecQos.ImpersonationType = RPC_C_IMP_LEVEL_IMPERSONATE;
  57. RpcStatus = RpcBindingSetAuthInfoEx(BindingHandle,
  58. L"NT Authority\\SYSTEM",
  59. RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
  60. RPC_C_AUTHN_WINNT,
  61. NULL,
  62. RPC_C_AUTHZ_NONE,
  63. &RpcSecQos);
  64. }
  65. if(RpcStatus != RPC_S_OK)
  66. {
  67. BindingHandle = NULL;
  68. }
  69. RpcStringFreeW(&StringBinding);
  70. }
  71. return(BindingHandle);
  72. }
  73. void
  74. STRING_HANDLE_unbind (
  75. STRING_HANDLE lpStr,
  76. handle_t BindingHandle)
  77. /*++
  78. Routine Description:
  79. This routine calls a common unbind routine that is shared by
  80. all services.
  81. This routine is called from the server service client stubs when
  82. it is necessary to unbind to a server.
  83. Arguments:
  84. ServerName - This is the name of the server from which to unbind.
  85. BindingHandle - This is the binding handle that is to be closed.
  86. Return Value:
  87. none.
  88. --*/
  89. {
  90. RPC_STATUS RpcStatus;
  91. RpcStatus = RpcBindingFree(&BindingHandle);
  92. ASSERT(RpcStatus == RPC_S_OK);
  93. return;
  94. }