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.

74 lines
1.9 KiB

  1. /********************************************************************/
  2. /** Copyright(c) 1989 Microsoft Corporation. **/
  3. /********************************************************************/
  4. //***
  5. //
  6. // Filename: rpcutil.c
  7. //
  8. // Description: Contains RPC utiliry routines.
  9. //
  10. // History: May 11,1995. NarenG Created original version.
  11. //
  12. #include <nt.h>
  13. #include <ntrtl.h> // For ASSERT
  14. #include <nturtl.h> // needed for winbase.h
  15. #include <windows.h> // Win32 base API's
  16. #include <rpc.h>
  17. #include <ntseapi.h>
  18. #include <dimsvcp.h> // For DIM_SERVICE_NAME
  19. #include <ntlsa.h>
  20. #include <ntsam.h>
  21. #include <ntsamp.h>
  22. #include <nturtl.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <wchar.h>
  26. #include <dimsvc.h>
  27. //**
  28. //
  29. // Call: DimRPCBind
  30. //
  31. // Returns: NO_ERROR - success
  32. // non-sero returns from RPC calls.
  33. //
  34. // Description: This routine is called when it is necessary to bind to a server.
  35. // The binding is done to allow impersonation by the server since
  36. // that is necessary for the API calls.
  37. //
  38. DWORD
  39. DimRPCBind(
  40. IN LPWSTR lpwsServerName,
  41. OUT HANDLE * phDimServer
  42. )
  43. {
  44. RPC_STATUS RpcStatus;
  45. LPWSTR lpwsStringBinding;
  46. RpcStatus = RpcStringBindingCompose(
  47. NULL,
  48. TEXT("ncacn_np"),
  49. lpwsServerName,
  50. TEXT("\\PIPE\\ROUTER"),
  51. TEXT("Security=Impersonation Static True"),
  52. &lpwsStringBinding);
  53. if ( RpcStatus != RPC_S_OK )
  54. {
  55. return( RpcStatus );
  56. }
  57. RpcStatus = RpcBindingFromStringBinding( lpwsStringBinding,
  58. (handle_t *)phDimServer );
  59. RpcStringFree( &lpwsStringBinding );
  60. if ( RpcStatus != RPC_S_OK )
  61. {
  62. return( RpcStatus );
  63. }
  64. return( NO_ERROR );
  65. }