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. DelObj.c
  5. Abstract:
  6. Command line test tool for removing an object from 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 hParentObject = NULL;
  16. OEM_STRING OemArg;
  17. UNICODE_STRING ParentObjectName;
  18. WCHAR lpParentObjectName[256];
  19. UNICODE_STRING ObjectName;
  20. WCHAR ObjectNameBuffer[48]; // Max object name length.
  21. ParentObjectName.Length = 0;
  22. ParentObjectName.MaximumLength = sizeof( lpParentObjectName );
  23. ParentObjectName.Buffer = lpParentObjectName;
  24. //
  25. // Check the arguments.
  26. //
  27. if ( argc != 3 )
  28. {
  29. printf( "\nUsage: delobj <parent object DN> <object name>\n" );
  30. printf( "\n where:\n" );
  31. printf( " parent object DN = \\\\tree\\xxx.yyy.zzz\n" );
  32. printf( " object name = The name of the object to remove, no spaces\n" );
  33. printf( "\nFor Example:\n" );
  34. printf( " delobj \\\\MARSDEV\\OU=DEV.O=MARS TESTUSER\n\n" );
  35. return -1;
  36. }
  37. OemArg.Length = strlen( argv[1] );
  38. OemArg.MaximumLength = OemArg.Length;
  39. OemArg.Buffer = argv[1];
  40. RtlOemStringToUnicodeString( &ParentObjectName, &OemArg, FALSE );
  41. status = NwNdsOpenObject( ParentObjectName.Buffer,
  42. NULL,
  43. NULL,
  44. &hParentObject,
  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. ObjectName.Length = 0;
  62. ObjectName.MaximumLength = sizeof( ObjectNameBuffer );
  63. ObjectName.Buffer = ObjectNameBuffer;
  64. RtlOemStringToUnicodeString( &ObjectName, &OemArg, FALSE );
  65. printf( "Removing the object from tree\n" );
  66. status = NwNdsRemoveObject( hParentObject, ObjectName.Buffer );
  67. if ( status )
  68. {
  69. printf( "\nError: NwNdsRemoveObject returned status 0x%.8X\n\n", status );
  70. return -1;
  71. }
  72. status = NwNdsCloseObject( hParentObject );
  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. }