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.

159 lines
3.6 KiB

  1. /***
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. ModObj.c
  5. Abstract:
  6. Command line test tool for modifying 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. HANDLE hOperationData = NULL;
  17. OEM_STRING OemArg;
  18. UNICODE_STRING ObjectName;
  19. WCHAR lpObjectName[256];
  20. WCHAR lpTextBuffer[256];
  21. ASN1_TYPE_11 asn11;
  22. ObjectName.Length = 0;
  23. ObjectName.MaximumLength = sizeof( lpObjectName );
  24. ObjectName.Buffer = lpObjectName;
  25. asn11.TelephoneNumber = (LPWSTR) lpTextBuffer;
  26. asn11.NumberOfBits = 0;
  27. asn11.Parameters = NULL;
  28. //
  29. // Check the arguments.
  30. //
  31. if ( argc != 2 )
  32. {
  33. printf( "Usage: modobj <object DN>\n" );
  34. printf( "For Example: modobj \\\\MARSDEV\\CN=TESTUSER.OU=DEV.O=MARS\n" );
  35. printf( "\nUsage: modobj <object DN>\n" );
  36. printf( "\n where:\n" );
  37. printf( " object DN = \\\\tree\\xxx.yyy.zzz\n" );
  38. printf( "\nFor Example:\n" );
  39. printf( " modobj \\\\MARSDEV\\CN=TEST.OU=DEV.O=MARS\n\n" );
  40. return -1;
  41. }
  42. OemArg.Length = strlen( argv[1] );
  43. OemArg.MaximumLength = OemArg.Length;
  44. OemArg.Buffer = argv[1];
  45. RtlOemStringToUnicodeString( &ObjectName, &OemArg, FALSE );
  46. status = NwNdsOpenObject( ObjectName.Buffer,
  47. NULL,
  48. NULL,
  49. &hObject,
  50. NULL,
  51. NULL,
  52. NULL,
  53. NULL,
  54. NULL );
  55. if ( status )
  56. {
  57. printf( "\nError: NwNdsOpenObject returned status 0x%.8X\n\n", status );
  58. return -1;
  59. }
  60. //
  61. // Prepare buffer with list of attribute changes
  62. //
  63. status = NwNdsCreateBuffer( NDS_OBJECT_MODIFY, &hOperationData );
  64. if ( status )
  65. {
  66. printf( "\nError: NwNdsCreateBuffer returned status 0x%.8X\n\n", status );
  67. return -1;
  68. }
  69. printf( "Put value NDS_FAX_NUMBER, NDS_ATTR_CLEAR into attributes buffer\n" );
  70. status = NwNdsPutInBuffer( NDS_FAX_NUMBER,
  71. NULL,
  72. 0,
  73. NDS_ATTR_CLEAR,
  74. hOperationData );
  75. if ( status )
  76. {
  77. printf( "\nError: NwNdsPutInBuffer returned status 0x%.8X\n\n", status );
  78. return -1;
  79. }
  80. wcscpy( asn11.TelephoneNumber, L"1 (425) 936-9687" );
  81. printf( "Put value NDS_FAX_NUMBER, NDS_ATTR_ADD:\"1 (425) 936-9687\" into attributes buffer\n" );
  82. status = NwNdsPutInBuffer( NDS_FAX_NUMBER,
  83. &asn11,
  84. 1,
  85. NDS_ATTR_ADD,
  86. hOperationData );
  87. if ( status )
  88. {
  89. printf( "\nError: NwNdsPutInBuffer returned status 0x%.8X\n\n", status );
  90. return -1;
  91. }
  92. printf( "Modifying the object in tree\n" );
  93. status = NwNdsModifyObject( hObject, hOperationData );
  94. if ( status )
  95. {
  96. printf( "\nError: NwNdsModifyObject returned status 0x%.8X\n\n", status );
  97. return -1;
  98. }
  99. status = NwNdsFreeBuffer( hOperationData );
  100. if ( status )
  101. {
  102. printf( "\nError: NwNdsFreeBuffer returned status 0x%.8X\n\n", status );
  103. return -1;
  104. }
  105. status = NwNdsCloseObject( hObject );
  106. if ( status )
  107. {
  108. printf( "\nError: NwNdsCloseObject returned status 0x%.8X\n\n", status );
  109. return -1;
  110. }
  111. return status;
  112. }