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.

117 lines
3.2 KiB

  1. /*---------------------------------------------------------------------------
  2. File: PwdRpcUtil.cpp
  3. Comments: Functions to establish binding to Password Migration Lsa
  4. Notifications packages. These functions are used by the password extension
  5. to bind to the password migration Lsa notification package on remote source
  6. domain DCs.
  7. This files was copied from AgRpcUtil.cpp, which was created by Christy Boles
  8. of NetIQ Corporation.
  9. REVISION LOG ENTRY
  10. Revision By: Paul Thompson
  11. Revised on 09/04/00
  12. ---------------------------------------------------------------------------
  13. */
  14. //#include "StdAfx.h"
  15. #include <windows.h>
  16. #include <rpc.h>
  17. #include <rpcdce.h>
  18. // These global variables can be changed if required
  19. #define gsPwdProtoSeq TEXT("ncacn_np")
  20. #define gsPwdEndPoint TEXT("\\pipe\\PwdMigRpc")
  21. // Destroy RPC binding for connection with an Lsa notification package
  22. DWORD // ret-OS return code
  23. PwdBindDestroy(
  24. handle_t * phBinding ,// i/o-binding handle
  25. TCHAR ** psBinding // i/o-binding string
  26. )
  27. {
  28. if ( *phBinding )
  29. {
  30. RpcBindingFree( phBinding );
  31. *phBinding = NULL;
  32. }
  33. if ( *psBinding )
  34. {
  35. RpcStringFree( psBinding );
  36. *psBinding = NULL;
  37. }
  38. return 0;
  39. }
  40. // Create RPC binding for connection with an Lsa notification package
  41. DWORD // ret-OS return code
  42. PwdBindCreate(
  43. TCHAR const * sComputer ,// in -computer name
  44. handle_t * phBinding ,// out-binding handle
  45. TCHAR ** psBinding ,// out-binding string
  46. BOOL bAuthn // in -flag whether to use authenticated RPC
  47. )
  48. {
  49. DWORD rcOs; // OS return code
  50. do // once or until break
  51. {
  52. PwdBindDestroy( phBinding, psBinding );
  53. rcOs = RpcStringBindingCompose(
  54. NULL,
  55. (TCHAR *) gsPwdProtoSeq,
  56. (TCHAR *) sComputer,
  57. (TCHAR *) gsPwdEndPoint,
  58. NULL,
  59. psBinding );
  60. if ( rcOs ) break;
  61. rcOs = RpcBindingFromStringBinding( *psBinding, phBinding );
  62. if ( rcOs || !bAuthn ) break;
  63. rcOs = RpcBindingSetAuthInfo(
  64. *phBinding,
  65. 0,
  66. RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
  67. RPC_C_AUTHN_WINNT,
  68. 0,
  69. 0 );
  70. } while ( FALSE );
  71. if ( rcOs )
  72. {
  73. PwdBindDestroy( phBinding, psBinding );
  74. }
  75. return rcOs;
  76. }
  77. /*/////////////////////////////////////////////////////////////////////////////
  78. // midl allocate memory
  79. ///////////////////////////////////////////////////////////////////////////////
  80. void __RPC_FAR * __RPC_USER
  81. midl_user_allocate(
  82. size_t len )
  83. {
  84. return new char[len];
  85. }
  86. ///////////////////////////////////////////////////////////////////////////////
  87. // midl free memory
  88. ///////////////////////////////////////////////////////////////////////////////
  89. void __RPC_USER
  90. midl_user_free(
  91. void __RPC_FAR * ptr )
  92. {
  93. delete [] ptr;
  94. return;
  95. }
  96. */