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.

133 lines
2.4 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1996
  5. //
  6. // File: cprov.cxx
  7. //
  8. // Contents: LDAP Provider Object Class Factory Code
  9. //
  10. // CLDAPProvider
  11. //
  12. // History: 06-15-96 yihsins Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "ldap.hxx"
  16. #pragma hdrstop
  17. // Class CLDAPProvider
  18. CLDAPProvider::CLDAPProvider()
  19. {
  20. ENLIST_TRACKING(CLDAPProvider);
  21. }
  22. HRESULT
  23. CLDAPProvider::Create(CLDAPProvider FAR * FAR * ppProvider)
  24. {
  25. CLDAPProvider FAR * pProvider = NULL;
  26. HRESULT hr = S_OK;
  27. //Create the Provider Object
  28. pProvider = new CLDAPProvider();
  29. if (pProvider == NULL) {
  30. RRETURN_EXP_IF_ERR(E_OUTOFMEMORY);
  31. }
  32. if (FAILED(hr)) {
  33. delete pProvider;
  34. RRETURN(hr);
  35. }
  36. *ppProvider = pProvider;
  37. RRETURN_EXP_IF_ERR(hr);
  38. }
  39. CLDAPProvider::~CLDAPProvider( )
  40. {
  41. }
  42. STDMETHODIMP
  43. CLDAPProvider::QueryInterface(REFIID iid, LPVOID FAR* ppv)
  44. {
  45. if (ppv == NULL) {
  46. RRETURN(E_POINTER);
  47. }
  48. if (IsEqualIID(iid, IID_IUnknown))
  49. {
  50. *ppv = this;
  51. }
  52. else if (IsEqualIID(iid, IID_IParseDisplayName))
  53. {
  54. *ppv = (IADs FAR *) this;
  55. }
  56. else
  57. {
  58. *ppv = NULL;
  59. return E_NOINTERFACE;
  60. }
  61. AddRef();
  62. return NOERROR;
  63. }
  64. STDMETHODIMP
  65. CLDAPProvider::ParseDisplayName(IBindCtx* pbc, TCHAR* szDisplayName, ULONG* pchEaten, IMoniker** ppmk)
  66. {
  67. HRESULT hr;
  68. *ppmk = NULL;
  69. if (pchEaten != NULL){
  70. *pchEaten = 0;
  71. }
  72. hr = ResolvePathName(
  73. pbc,
  74. szDisplayName,
  75. pchEaten,
  76. ppmk
  77. );
  78. RRETURN_EXP_IF_ERR(hr);
  79. }
  80. HRESULT
  81. CLDAPProvider::ResolvePathName(IBindCtx* pbc,
  82. TCHAR* szDisplayName,
  83. ULONG* pchEaten,
  84. IMoniker** ppmk
  85. )
  86. {
  87. HRESULT hr;
  88. LPUNKNOWN pUnknown = NULL;
  89. CCredentials Credentials;
  90. if (!pchEaten) {
  91. BAIL_IF_ERROR(hr = E_INVALIDARG);
  92. }
  93. *pchEaten = 0;
  94. hr = GetObject(
  95. szDisplayName,
  96. Credentials,
  97. (LPVOID *)&pUnknown
  98. );
  99. BAIL_IF_ERROR(hr);
  100. hr = CreatePointerMoniker(pUnknown, ppmk);
  101. BAIL_IF_ERROR(hr);
  102. *pchEaten += _tcslen(szDisplayName);
  103. cleanup:
  104. if (pUnknown) {
  105. pUnknown->Release();
  106. }
  107. RRETURN_EXP_IF_ERR(hr);
  108. }