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.

242 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1991-1993 Microsoft Corporation
  3. Module Name:
  4. bind.c
  5. Abstract:
  6. Contains the client-side RPC bind and unbind routines for Workstation
  7. service.
  8. Author:
  9. Rita Wong (ritaw) 12-Feb-1993
  10. Environment:
  11. User Mode -Win32
  12. Revision History:
  13. --*/
  14. //
  15. // INCLUDES
  16. //
  17. #include <nwclient.h>
  18. #include <rpcutil.h> // RpcUtils for binding
  19. #include <nwmisc.h> // NWWKS_INTERFACE_NAME
  20. handle_t
  21. NWWKSTA_IMPERSONATE_HANDLE_bind(
  22. NWWKSTA_IMPERSONATE_HANDLE Reserved
  23. )
  24. /*++
  25. Routine Description:
  26. This routine is called from the Workstation service client when
  27. it is necessary create an RPC binding to the server end with
  28. impersonation level of impersonation.
  29. Arguments:
  30. Return Value:
  31. The binding handle is returned to the stub routine. If the bind is
  32. unsuccessful, a NULL will be returned.
  33. --*/
  34. {
  35. handle_t BindHandle = 0;
  36. RPC_STATUS RpcStatus;
  37. LPWSTR binding = NULL;
  38. UNREFERENCED_PARAMETER(Reserved);
  39. /*
  40. RpcStatus = NetpBindRpc(
  41. NULL,
  42. NWWKS_INTERFACE_NAME,
  43. L"Security=Impersonation Dynamic False",
  44. &BindHandle
  45. );
  46. */
  47. RpcStatus = RpcStringBindingComposeW(
  48. 0,
  49. L"ncalrpc",
  50. NULL,
  51. L"nwwkslpc",
  52. L"Security=Impersonation Dynamic False",
  53. &binding );
  54. if ( RpcStatus != RPC_S_OK )
  55. {
  56. return NULL;
  57. }
  58. RpcStatus = RpcBindingFromStringBindingW( binding, &BindHandle );
  59. if ( RpcStatus != RPC_S_OK )
  60. {
  61. BindHandle = NULL;
  62. }
  63. if ( binding )
  64. {
  65. RpcStringFreeW( &binding );
  66. }
  67. if (RpcStatus != RPC_S_OK) {
  68. KdPrint((
  69. "NWWORKSTATION: Client NWWKSTA_IMPERSONATE_HANDLE_bind failed: %lu\n",
  70. RpcStatus
  71. ));
  72. }
  73. return BindHandle;
  74. }
  75. handle_t
  76. NWWKSTA_IDENTIFY_HANDLE_bind(
  77. NWWKSTA_IDENTIFY_HANDLE Reserved
  78. )
  79. /*++
  80. Routine Description:
  81. This routine is called from the Workstation service client stubs when
  82. it is necessary create an RPC binding to the server end with
  83. identification level of impersonation.
  84. Arguments:
  85. Return Value:
  86. The binding handle is returned to the stub routine. If the bind is
  87. unsuccessful, a NULL will be returned.
  88. --*/
  89. {
  90. handle_t BindHandle = 0;
  91. RPC_STATUS RpcStatus;
  92. LPWSTR binding = NULL;
  93. UNREFERENCED_PARAMETER(Reserved);
  94. /*
  95. RpcStatus = NetpBindRpc(
  96. NULL,
  97. NWWKS_INTERFACE_NAME,
  98. L"Security=Identification Dynamic False",
  99. &BindHandle
  100. );
  101. */
  102. RpcStatus = RpcStringBindingComposeW(
  103. 0,
  104. L"ncalrpc",
  105. NULL,
  106. L"nwwkslpc",
  107. L"Security=Identification Dynamic False",
  108. &binding );
  109. if ( RpcStatus != RPC_S_OK )
  110. {
  111. return NULL;
  112. }
  113. RpcStatus = RpcBindingFromStringBindingW( binding, &BindHandle );
  114. if ( RpcStatus != RPC_S_OK )
  115. {
  116. BindHandle = NULL;
  117. }
  118. if ( binding )
  119. {
  120. RpcStringFreeW( &binding );
  121. }
  122. if (RpcStatus != RPC_S_OK) {
  123. KdPrint((
  124. "NWWORKSTATION: Client NWWKSTA_IDENTIFY_HANDLE_bind failed: %lu\n",
  125. RpcStatus
  126. ));
  127. }
  128. return BindHandle;
  129. }
  130. void
  131. NWWKSTA_IMPERSONATE_HANDLE_unbind(
  132. NWWKSTA_IMPERSONATE_HANDLE Reserved,
  133. handle_t BindHandle
  134. )
  135. /*++
  136. Routine Description:
  137. This routine unbinds the impersonation generic handle.
  138. Arguments:
  139. Reserved -
  140. BindingHandle - This is the binding handle that is to be closed.
  141. Return Value:
  142. None.
  143. --*/
  144. {
  145. UNREFERENCED_PARAMETER(Reserved);
  146. // NetpUnbindRpc(BindHandle);
  147. RpcBindingFree( &BindHandle );
  148. }
  149. void
  150. NWWKSTA_IDENTIFY_HANDLE_unbind(
  151. NWWKSTA_IDENTIFY_HANDLE Reserved,
  152. handle_t BindHandle
  153. )
  154. /*++
  155. Routine Description:
  156. This routine unbinds the identification generic handle.
  157. Arguments:
  158. Reserved -
  159. BindingHandle - This is the binding handle that is to be closed.
  160. Return Value:
  161. None.
  162. --*/
  163. {
  164. UNREFERENCED_PARAMETER(Reserved);
  165. // NetpUnbindRpc(BindHandle);
  166. RpcBindingFree( &BindHandle );
  167. }