Leaked source code of windows server 2003
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.

69 lines
1.8 KiB

  1. // Pop2Exch.cpp : Defines the entry point for the console application.
  2. //
  3. #include "stdafx.h"
  4. #include "P2EWorker.h"
  5. #include <atlbase.h>
  6. #include <checkuser.h> //IsUserInGroup
  7. int _cdecl wmain(int argc, wchar_t* argv[])
  8. {
  9. HRESULT hr = S_OK;
  10. CP2EWorker oWorker;
  11. CHAR szConsoleCP[8];
  12. setlocale( LC_ALL, "" );
  13. if ( 0 < _snprintf( szConsoleCP, 7, ".%d", GetConsoleOutputCP() ))
  14. setlocale( LC_CTYPE, szConsoleCP );
  15. // Command check
  16. if ( S_OK != IsUserInGroup(DOMAIN_ALIAS_RID_ADMINS)) // Admin check
  17. hr = E_ACCESSDENIED;
  18. if ( S_OK == hr )
  19. { // Check for /?
  20. if ( 1 < argc )
  21. {
  22. for ( int i = 1; i < argc; i++ )
  23. {
  24. if (( 0 == _wcsicmp( L"/?", argv[i] )) || ( 0 == _wcsicmp( L"-?", argv[i] )))
  25. hr = -1;
  26. }
  27. }
  28. else
  29. hr = -1;
  30. }
  31. if ( S_OK == hr )
  32. {
  33. hr = CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
  34. if ( S_OK == hr )
  35. {
  36. if ( 0 == _wcsicmp( L"CREATEUSER", argv[1] ))
  37. {
  38. hr = oWorker.CreateUser( argc, argv, true, false );
  39. }
  40. else if ( 0 == _wcsicmp( L"CREATEMAILBOX", argv[1] ))
  41. {
  42. hr = oWorker.CreateUser( argc, argv, false, true );
  43. }
  44. else if ( 0 == _wcsicmp( L"SENDMAIL", argv[1] ))
  45. {
  46. hr = oWorker.Mail( argc, argv );
  47. }
  48. else
  49. hr = -1;
  50. CoUninitialize();
  51. }
  52. }
  53. if ( -1 == hr )
  54. {
  55. oWorker.PrintUsage();
  56. }
  57. else if ( 0 != hr )
  58. {
  59. oWorker.PrintError( hr );
  60. }
  61. return hr;
  62. }