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.

106 lines
2.6 KiB

  1. /***
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. ChngPass.c
  5. Abstract:
  6. Command line test tool for changing a password on a user object in
  7. a NDS tree.
  8. Author:
  9. Glenn Curtis [glennc] 05-Jan-96
  10. ***/
  11. #include <utils.c>
  12. int
  13. _cdecl main( int argc, char **argv )
  14. {
  15. DWORD status = NO_ERROR;
  16. HANDLE hObject = NULL;
  17. OEM_STRING OemArg;
  18. UNICODE_STRING ObjectName;
  19. WCHAR lpObjectName[256];
  20. WCHAR lpOldPassword[256];
  21. WCHAR lpNewPassword[256];
  22. ObjectName.Length = 0;
  23. ObjectName.MaximumLength = sizeof( lpObjectName );
  24. ObjectName.Buffer = lpObjectName;
  25. //
  26. // Check the arguments.
  27. //
  28. if ( argc != 2 )
  29. {
  30. printf( "\nUsage: chngpass <user object DN>\n" );
  31. printf( "\n where:\n" );
  32. printf( " user object DN = \\\\tree\\joe.yyy.zzz\n" );
  33. printf( "\nFor Example: chngpass \\\\MARSDEV\\CN=USER1.OU=DEV.O=MARS\n\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. if ( status = NwNdsOpenObject( ObjectName.Buffer,
  41. NULL,
  42. NULL,
  43. &hObject,
  44. NULL,
  45. NULL,
  46. NULL,
  47. NULL,
  48. NULL ) != NO_ERROR )
  49. {
  50. printf( "\nError: NwNdsOpenObject returned status %ld\n\n", status );
  51. printf( "\nError: GetLastError returned: 0x%.8X\n\n",
  52. GetLastError() );
  53. return -1;
  54. }
  55. printf( "\nPlease enter your old password : " );
  56. GetStringOrDefault( lpOldPassword, L"" );
  57. printf( "\nPlease enter your new password : " );
  58. GetStringOrDefault( lpNewPassword, L"" );
  59. if ( status = NwNdsChangeUserPassword( hObject,
  60. lpOldPassword,
  61. lpNewPassword ) != NO_ERROR )
  62. {
  63. printf( "\nError: NwNdsChangeUserPassword returned status %ld\n\n", status );
  64. printf( "\nError: GetLastError returned: 0x%.8X\n\n",
  65. GetLastError() );
  66. return -1;
  67. }
  68. if ( status = NwNdsCloseObject( hObject ) != NO_ERROR )
  69. {
  70. printf( "\nError: NwNdsCloseObject returned status %ld\n\n", status );
  71. printf( "\nError: GetLastError returned: 0x%.8X\n\n",
  72. GetLastError() );
  73. return -1;
  74. }
  75. printf( "\nUser password successfully changed\n\n" );
  76. }