LogonHelper.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* Copyright (C) 2014-2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using Utilities;
  10. namespace SMBLibrary.Server
  11. {
  12. public class LogonHelper
  13. {
  14. public static NTStatus ToNTStatus(Win32Error errorCode)
  15. {
  16. switch (errorCode)
  17. {
  18. case Win32Error.ERROR_ACCOUNT_RESTRICTION:
  19. return NTStatus.STATUS_ACCOUNT_RESTRICTION;
  20. case Win32Error.ERROR_INVALID_LOGON_HOURS:
  21. return NTStatus.STATUS_INVALID_LOGON_HOURS;
  22. case Win32Error.ERROR_INVALID_WORKSTATION:
  23. return NTStatus.STATUS_INVALID_WORKSTATION;
  24. case Win32Error.ERROR_PASSWORD_EXPIRED:
  25. return NTStatus.STATUS_PASSWORD_EXPIRED;
  26. case Win32Error.ERROR_ACCOUNT_DISABLED:
  27. return NTStatus.STATUS_ACCOUNT_DISABLED;
  28. case Win32Error.ERROR_LOGON_TYPE_NOT_GRANTED:
  29. return NTStatus.STATUS_LOGON_TYPE_NOT_GRANTED;
  30. case Win32Error.ERROR_ACCOUNT_EXPIRED:
  31. return NTStatus.STATUS_ACCOUNT_EXPIRED;
  32. case Win32Error.ERROR_PASSWORD_MUST_CHANGE:
  33. return NTStatus.STATUS_PASSWORD_MUST_CHANGE;
  34. case Win32Error.ERROR_ACCOUNT_LOCKED_OUT:
  35. return NTStatus.STATUS_ACCOUNT_LOCKED_OUT;
  36. default:
  37. return NTStatus.STATUS_LOGON_FAILURE;
  38. }
  39. }
  40. }
  41. }