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.

112 lines
2.3 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 2000, Microsoft Corporation
  4. //
  5. // File: DfsError.cxx
  6. //
  7. // Contents: Converts HRESULT to DFSSTATUS
  8. //
  9. // Classes: none.
  10. //
  11. // History: April. 09 2001, Author: Rohanp
  12. //
  13. //-----------------------------------------------------------------------------
  14. #include <windows.h>
  15. #include <ole2.h>
  16. #include <activeds.h>
  17. #include <dfsheader.h>
  18. #include <dfsError.hxx>
  19. /////////////////////////////////////////////
  20. //
  21. // Error message specific to ADSI
  22. //
  23. ////////////////////////////////////////////
  24. DFSSTATUS
  25. DfsGetADSIError( HRESULT hr )
  26. {
  27. DFSSTATUS status = ERROR_SUCCESS;
  28. switch(hr)
  29. {
  30. case S_OK:
  31. status = ERROR_SUCCESS;
  32. break;
  33. case E_ADS_BAD_PATHNAME:
  34. case E_ADS_INVALID_DOMAIN_OBJECT:
  35. case E_ADS_INVALID_USER_OBJECT:
  36. case E_ADS_INVALID_COMPUTER_OBJECT:
  37. status = ERROR_BAD_NET_NAME;
  38. break;
  39. case E_ADS_UNKNOWN_OBJECT:
  40. case E_ADS_PROPERTY_INVALID:
  41. case E_ADS_BAD_PARAMETER:
  42. case E_ADS_PROPERTY_NOT_SET:
  43. status = ERROR_INVALID_PARAMETER;
  44. break;
  45. case E_NOTIMPL:
  46. status = ERROR_CALL_NOT_IMPLEMENTED;
  47. break;
  48. case E_NOINTERFACE:
  49. case E_ADS_PROPERTY_NOT_FOUND:
  50. status = ERROR_NOT_FOUND;
  51. break;
  52. case E_ADS_PROPERTY_NOT_SUPPORTED:
  53. status = ERROR_NOT_SUPPORTED;
  54. break;
  55. case E_POINTER:
  56. status = ERROR_INVALID_HANDLE;
  57. break;
  58. case E_ADS_SCHEMA_VIOLATION:
  59. status = ERROR_DS_CONSTRAINT_VIOLATION;
  60. break;
  61. case E_ABORT:
  62. status = ERROR_OPERATION_ABORTED;
  63. break;
  64. case E_FAIL:
  65. case E_UNEXPECTED:
  66. default:
  67. status = ERROR_BAD_COMMAND;
  68. //ASSERT(FALSE);
  69. break;
  70. }
  71. return status;
  72. }
  73. DFSSTATUS
  74. DfsGetErrorFromHr( HRESULT hr )
  75. {
  76. DFSSTATUS Status = ERROR_SUCCESS;
  77. if(hr == S_OK)
  78. {
  79. Status = ERROR_SUCCESS;
  80. }
  81. else if ( (ULONG)hr & 0x00005000) // standard ADSI Errors
  82. {
  83. Status = DfsGetADSIError(hr);
  84. }
  85. else if ( HRESULT_FACILITY(hr)==FACILITY_WIN32 )
  86. {
  87. Status = hr & 0x0000FFFF;
  88. }
  89. else
  90. {
  91. Status = ERROR_BAD_COMMAND;
  92. }
  93. return Status;
  94. }