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.

116 lines
2.6 KiB

  1. /***
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. MoveObj.c
  5. Abstract:
  6. Command line test tool for moving an object in a NDS tree.
  7. Author:
  8. Glenn Curtis [glennc] 05-Jan-96
  9. ***/
  10. #include <utils.c>
  11. int
  12. _cdecl main( int argc, char **argv )
  13. {
  14. DWORD status = NO_ERROR;
  15. HANDLE hObject = NULL;
  16. OEM_STRING OemArg;
  17. UNICODE_STRING ObjectName;
  18. WCHAR lpObjectName[256];
  19. UNICODE_STRING DestContainerName;
  20. WCHAR lpDestContainerName[256];
  21. //
  22. // Check the arguments.
  23. //
  24. if ( argc != 3 )
  25. {
  26. printf( "\nUsage: moveobj <object DN> <destination container DN>\n" );
  27. printf( "\n where:\n" );
  28. printf( " object DN = \\\\tree\\xxx.yyy.zzz\n" );
  29. printf( " destination container DN = \\\\tree\\zzz\n" );
  30. printf( "\nFor Example:\n" );
  31. printf( " moveobj \\\\MARSDEV\\CN=FRED.OU=DEV.O=MARS \\\\MARSDEV\\O=MARS\n\n" );
  32. return -1;
  33. }
  34. OemArg.Length = strlen( argv[1] );
  35. OemArg.MaximumLength = OemArg.Length;
  36. OemArg.Buffer = argv[1];
  37. ObjectName.Length = 0;
  38. ObjectName.MaximumLength = sizeof( lpObjectName );
  39. ObjectName.Buffer = lpObjectName;
  40. RtlOemStringToUnicodeString( &ObjectName, &OemArg, FALSE );
  41. status = NwNdsOpenObject( ObjectName.Buffer,
  42. NULL,
  43. NULL,
  44. &hObject,
  45. NULL,
  46. NULL,
  47. NULL,
  48. NULL,
  49. NULL );
  50. if ( status )
  51. {
  52. printf( "\nError: NwNdsOpenObject returned status 0x%.8X\n\n", status );
  53. return -1;
  54. }
  55. //
  56. // Prepare the new object's name
  57. //
  58. OemArg.Length = strlen( argv[2] );
  59. OemArg.MaximumLength = OemArg.Length;
  60. OemArg.Buffer = argv[2];
  61. DestContainerName.Length = 0;
  62. DestContainerName.MaximumLength = sizeof( lpDestContainerName );
  63. DestContainerName.Buffer = lpDestContainerName;
  64. RtlOemStringToUnicodeString( &DestContainerName, &OemArg, FALSE );
  65. printf( "Moving the object in the tree\n" );
  66. status = NwNdsMoveObject( hObject, DestContainerName.Buffer );
  67. if ( status )
  68. {
  69. printf( "\nError: NwNdsMoveObject returned status 0x%.8X\n\n", status );
  70. return -1;
  71. }
  72. status = NwNdsCloseObject( hObject );
  73. if ( status )
  74. {
  75. printf( "\nError: NwNdsCloseObject returned status 0x%.8X\n\n", status );
  76. return -1;
  77. }
  78. printf( "\nSuccess!\n\n" );
  79. return status;
  80. }