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.

113 lines
2.7 KiB

  1. /***
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. GetR(i)ghts.c
  5. Abstract:
  6. Command line test tool for testing the NDS GetEffectiveRights API.
  7. Author:
  8. Glenn Curtis [glennc] 22-Apr-96
  9. ***/
  10. #include <utils.c>
  11. int
  12. _cdecl main( int argc, char **argv )
  13. {
  14. DWORD status = NO_ERROR;
  15. HANDLE hObject;
  16. OEM_STRING OemArg;
  17. UNICODE_STRING ObjectName;
  18. WCHAR lpObjectName[256];
  19. WCHAR TempName[256];
  20. WCHAR lpSubjectName[256];
  21. WCHAR lpAttributeName[256];
  22. DWORD dwRights;
  23. ObjectName.Length = 0;
  24. ObjectName.MaximumLength = sizeof( lpObjectName );
  25. ObjectName.Buffer = lpObjectName;
  26. //
  27. // Check the arguments.
  28. //
  29. if ( argc != 2 )
  30. {
  31. Usage:
  32. printf( "\nUsage: GetRights <Object Path>\n" );
  33. printf( " where: Object Path = \\\\<tree name>\\<Object distiguished name>\n" );
  34. return -1;
  35. }
  36. OemArg.Length = strlen( argv[1] );
  37. OemArg.MaximumLength = OemArg.Length;
  38. OemArg.Buffer = argv[1];
  39. RtlOemStringToUnicodeString( &ObjectName, &OemArg, FALSE );
  40. status = NwNdsOpenObject( ObjectName.Buffer,
  41. NULL,
  42. NULL,
  43. &hObject,
  44. NULL,
  45. NULL,
  46. NULL,
  47. NULL,
  48. NULL );
  49. if ( status )
  50. {
  51. printf( "\nError: NwNdsOpenObject returned status 0x%.8X\n", status );
  52. printf( "Error: GetLastError returned: 0x%.8X\n\n",
  53. GetLastError() );
  54. return -1;
  55. }
  56. printf( "Subject name (Ex. joe.sales.acme) : " );
  57. GetStringOrDefault( lpSubjectName, L"" );
  58. printf( "Attribute name (Ex. A particular attribute like Surname, [All Attributes Rights],\nor [Entry Rights]) : " );
  59. GetStringOrDefault( lpAttributeName, L"" );
  60. status = NwNdsGetEffectiveRights( hObject,
  61. lpSubjectName,
  62. lpAttributeName,
  63. &dwRights );
  64. if ( status )
  65. {
  66. printf( "\nError: NwNdsGetEffectiveRights returned status 0x%.8X\n", status );
  67. printf( "Error: GetLastError returned: 0x%.8X\n\n",
  68. GetLastError() );
  69. return -1;
  70. }
  71. printf( "NwNdsGetEffectiveRights returned: 0x%.8X\n\n", dwRights );
  72. status = NwNdsCloseObject( hObject );
  73. if ( status )
  74. {
  75. printf( "\nError: NwNdsCloseObject returned status 0x%.8X\n", status );
  76. printf( "Error: GetLastError returned: 0x%.8X\n\n",
  77. GetLastError() );
  78. return -1;
  79. }
  80. }