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.

143 lines
3.3 KiB

  1. /***
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. ListAttr.c
  5. Abstract:
  6. Command line test tool for listing all attributes of an object in a NDS tree.
  7. Author:
  8. Glenn Curtis [glennc] 25-Jan-96
  9. ***/
  10. #include <utils.c>
  11. int
  12. _cdecl main( int argc, char **argv )
  13. {
  14. DWORD status = NO_ERROR;
  15. LPBYTE lpTemp = NULL;
  16. DWORD dwValue;
  17. HANDLE hObject;
  18. HANDLE hOperationData = NULL;
  19. //
  20. // For GetFromBuffer function calls
  21. //
  22. LPNDS_ATTR_INFO lpEntries = NULL;
  23. DWORD NumberOfEntries = 0;
  24. OEM_STRING OemArg;
  25. UNICODE_STRING ObjectName;
  26. WCHAR lpObjectName[256];
  27. WCHAR szClassName[256];
  28. ObjectName.Length = 0;
  29. ObjectName.MaximumLength = sizeof( lpObjectName );
  30. ObjectName.Buffer = lpObjectName;
  31. //
  32. // Check the arguments.
  33. //
  34. if ( argc != 2 )
  35. {
  36. printf( "\nUsage: list <object DN>\n" );
  37. printf( "\n where:\n" );
  38. printf( " object DN = \\\\tree\\xxx.yyy.zzz\n" );
  39. printf( "\nFor Example: list \\\\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. szClassName,
  53. NULL,
  54. NULL );
  55. if ( status )
  56. {
  57. printf( "\nError: NwNdsOpenObject returned status 0x%.8X\n", status );
  58. printf( "Error: GetLastError returned: 0x%.8X\n\n",
  59. GetLastError() );
  60. return -1;
  61. }
  62. printf("Class Name is %ws\n", szClassName);
  63. status = NwNdsReadObject( hObject, NDS_INFO_NAMES_DEFS, &hOperationData );
  64. if ( status )
  65. {
  66. printf( "\nError: NwNdsReadObject returned status 0x%.8X\n", status );
  67. printf( "Error: GetLastError returned: 0x%.8X\n\n",
  68. GetLastError() );
  69. return -1;
  70. }
  71. status = NwNdsCloseObject( hObject );
  72. if ( status )
  73. {
  74. printf( "\nError: NwNdsCloseObject returned status 0x%.8X\n", status );
  75. printf( "Error: GetLastError returned: 0x%.8X\n\n",
  76. GetLastError() );
  77. return -1;
  78. }
  79. status = NwNdsGetAttrListFromBuffer( hOperationData,
  80. &NumberOfEntries,
  81. &lpEntries );
  82. if ( status )
  83. {
  84. printf( "\nError: NwNdsGetAttrListFromBuffer returned status 0x%.8X\n",
  85. status );
  86. printf( "Error: GetLastError returned: 0x%.8X\n\n",
  87. GetLastError() );
  88. return -1;
  89. }
  90. PrintObjectAttributeNamesAndValues( argv[1],
  91. argv[2],
  92. NumberOfEntries,
  93. lpEntries );
  94. status = NwNdsFreeBuffer( hOperationData );
  95. if ( status )
  96. {
  97. printf( "\nError: NwNdsFreeBuffer returned status 0x%.8X\n", status );
  98. printf( "Error: GetLastError returned: 0x%.8X\n\n",
  99. GetLastError() );
  100. return -1;
  101. }
  102. return status;
  103. }