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.

135 lines
3.4 KiB

  1. /***
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. NewName.c
  5. Abstract:
  6. Command line test tool for renaming an object in a NDS tree.
  7. Author:
  8. Glenn Curtis [glennc] 25-Jan-96
  9. ***/
  10. #include <ndsapi32.h>
  11. #include <nds32.h>
  12. int
  13. _cdecl main( int argc, char **argv )
  14. {
  15. DWORD status = NO_ERROR;
  16. LPBYTE lpTemp = NULL;
  17. DWORD dwValue;
  18. DWORD i;
  19. HANDLE hParentObject;
  20. HANDLE hOperationData = NULL;
  21. OEM_STRING OemArg;
  22. UNICODE_STRING ParentObjectName;
  23. UNICODE_STRING OldObjectName;
  24. UNICODE_STRING NewObjectName;
  25. WCHAR szParentObjectName[256];
  26. WCHAR szOldObjectName[256];
  27. WCHAR szNewObjectName[256];
  28. ParentObjectName.Length = 0;
  29. ParentObjectName.MaximumLength = sizeof( szParentObjectName );
  30. ParentObjectName.Buffer = szParentObjectName;
  31. OldObjectName.Length = 0;
  32. OldObjectName.MaximumLength = sizeof( szOldObjectName );
  33. OldObjectName.Buffer = szOldObjectName;
  34. NewObjectName.Length = 0;
  35. NewObjectName.MaximumLength = sizeof( szNewObjectName );
  36. NewObjectName.Buffer = szNewObjectName;
  37. //
  38. // Check the arguments.
  39. //
  40. if ( argc != 4 )
  41. {
  42. printf( "\nUsage: newname <parent object DN> <object name> <new object name>\n" );
  43. printf( "\n where:\n" );
  44. printf( " parent object DN = \\\\tree\\aaa.bbb\n" );
  45. printf( " object name = foo\n" );
  46. printf( " new object name = bar\n" );
  47. printf( "\nFor Example: newname \\\\MARSDEV\\OU=DEV.O=MARS glennc glenn_curtis\n\n" );
  48. return -1;
  49. }
  50. OemArg.Length = strlen( argv[1] );
  51. OemArg.MaximumLength = OemArg.Length;
  52. OemArg.Buffer = argv[1];
  53. RtlOemStringToUnicodeString( &ParentObjectName, &OemArg, FALSE );
  54. OemArg.Length = strlen( argv[2] );
  55. OemArg.MaximumLength = OemArg.Length;
  56. OemArg.Buffer = argv[2];
  57. RtlOemStringToUnicodeString( &OldObjectName, &OemArg, FALSE );
  58. OemArg.Length = strlen( argv[3] );
  59. OemArg.MaximumLength = OemArg.Length;
  60. OemArg.Buffer = argv[3];
  61. RtlOemStringToUnicodeString( &NewObjectName, &OemArg, FALSE );
  62. status = NwNdsOpenObject( ParentObjectName.Buffer,
  63. NULL,
  64. NULL,
  65. &hParentObject,
  66. NULL,
  67. NULL,
  68. NULL,
  69. NULL,
  70. NULL );
  71. if ( status )
  72. {
  73. printf( "\nError: NwNdsOpenObject returned status 0x%.8X\n\n", status );
  74. printf( "\nError: GetLastError returned: 0x%.8X\n\n",
  75. GetLastError() );
  76. return -1;
  77. }
  78. status = NwNdsRenameObject( hParentObject,
  79. OldObjectName.Buffer,
  80. NewObjectName.Buffer,
  81. TRUE );
  82. if ( status != NO_ERROR )
  83. {
  84. printf( "\nError: NwNdsRenameObject returned status 0x%.8X\n\n", status );
  85. printf( "\nError: GetLastError returned: 0x%.8X\n\n",
  86. GetLastError() );
  87. }
  88. else
  89. {
  90. printf( "\nNwNdsRenameObject succeeded!\n\n" );
  91. }
  92. status = NwNdsCloseObject( hParentObject );
  93. if ( status )
  94. {
  95. printf( "\nError: NwNdsCloseObject returned status 0x%.8X\n\n", status );
  96. printf( "\nError: GetLastError returned: 0x%.8X\n\n",
  97. GetLastError() );
  98. }
  99. return status;
  100. }