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.

212 lines
4.5 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. //
  4. // Microsoft Windows
  5. // Copyright (C) Microsoft Corporation, 1992 - 1995
  6. //
  7. // File: cdssch.cxx
  8. //
  9. // Contents: Microsoft ADs NDS Provider Generic Object
  10. //
  11. //
  12. // History: 03-02-97 ShankSh Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "nds.hxx"
  16. #pragma hdrstop
  17. static WCHAR gszObjClassAttr[] = L"Object Class";
  18. static WCHAR gszNameAttr[] = L"cn";
  19. HRESULT
  20. CNDSGenObject::EnumAttributes(
  21. LPWSTR * ppszAttrNames,
  22. DWORD dwNumAttributes,
  23. PADS_ATTR_DEF * ppAttrDefinition,
  24. DWORD * pdwNumAttributes
  25. )
  26. {
  27. HRESULT hr = S_OK;
  28. DWORD dwNumberOfEntries = 0;
  29. DWORD dwInfoType;
  30. LPNDS_ATTR_DEF lpAttrDefs = NULL;
  31. NDS_BUFFER_HANDLE hOperationData = NULL;
  32. DWORD i,j,k;
  33. DWORD dwMemSize = 0;
  34. LPBYTE pBuffer = NULL;
  35. LPWSTR pszNameEntry = NULL;
  36. PADS_ATTR_DEF pAttrDefEntry = NULL;
  37. if ( !ppAttrDefinition || !pdwNumAttributes ||
  38. (dwNumAttributes < 0 && dwNumAttributes != -1) ) {
  39. RRETURN (E_INVALIDARG);
  40. }
  41. *ppAttrDefinition = NULL;
  42. *pdwNumAttributes = NULL;
  43. hr = ADsNdsReadAttrDef(
  44. _hADsContext,
  45. DS_ATTR_DEFS,
  46. ppszAttrNames,
  47. dwNumAttributes,
  48. &hOperationData
  49. );
  50. BAIL_ON_FAILURE(hr);
  51. hr = ADsNdsGetAttrDefListFromBuffer(
  52. _hADsContext,
  53. hOperationData,
  54. &dwNumberOfEntries,
  55. &dwInfoType,
  56. &lpAttrDefs
  57. );
  58. BAIL_ON_FAILURE(hr);
  59. if (dwInfoType != DS_ATTR_DEFS )
  60. BAIL_ON_FAILURE( hr = E_FAIL );
  61. //
  62. // Now package this data into a single contiguous buffer
  63. //
  64. hr = ComputeADsAttrDefBufferSize(
  65. lpAttrDefs,
  66. dwNumberOfEntries,
  67. &dwMemSize
  68. );
  69. BAIL_ON_FAILURE(hr);
  70. pBuffer = (LPBYTE) AllocADsMem(dwMemSize);
  71. if (!pBuffer)
  72. BAIL_ON_FAILURE(hr = E_OUTOFMEMORY);
  73. pAttrDefEntry = (PADS_ATTR_DEF) pBuffer;
  74. pszNameEntry = (LPWSTR) (pBuffer + dwNumberOfEntries * sizeof(ADS_ATTR_DEF));
  75. for (j = 0; j < dwNumberOfEntries ; j++ ) {
  76. if (lpAttrDefs[j].dwSyntaxID >= g_cMapNdsTypeToADsType)
  77. pAttrDefEntry->dwADsType = ADSTYPE_INVALID;
  78. else
  79. pAttrDefEntry->dwADsType = g_MapNdsTypeToADsType[lpAttrDefs[j].dwSyntaxID];
  80. pAttrDefEntry->dwMinRange = lpAttrDefs[j].dwLowerLimit;
  81. pAttrDefEntry->dwMaxRange = lpAttrDefs[j].dwUpperLimit;
  82. pAttrDefEntry->fMultiValued = !(lpAttrDefs[j].dwFlags & NDS_SINGLE_VALUED_ATTR);
  83. wcscpy(pszNameEntry, lpAttrDefs[j].szAttributeName);
  84. pAttrDefEntry->pszAttrName = pszNameEntry;
  85. pszNameEntry += wcslen(lpAttrDefs[j].szAttributeName) + 1;
  86. pAttrDefEntry ++;
  87. }
  88. *ppAttrDefinition = (PADS_ATTR_DEF) pBuffer;
  89. *pdwNumAttributes = dwNumberOfEntries;
  90. error:
  91. if (hOperationData) {
  92. ADsNdsFreeBuffer(hOperationData);
  93. }
  94. ADsNdsFreeAttrDefList(lpAttrDefs, dwNumberOfEntries);
  95. RRETURN(hr);
  96. }
  97. HRESULT
  98. CNDSGenObject::CreateAttributeDefinition(
  99. LPWSTR pszAttributeName,
  100. PADS_ATTR_DEF pAttributeDefinition
  101. )
  102. {
  103. RRETURN (E_NOTIMPL);
  104. }
  105. HRESULT
  106. CNDSGenObject::WriteAttributeDefinition(
  107. LPWSTR pszAttributeName,
  108. PADS_ATTR_DEF pAttributeDefinition
  109. )
  110. {
  111. RRETURN (E_NOTIMPL);
  112. }
  113. HRESULT
  114. CNDSGenObject::DeleteAttributeDefinition(
  115. LPWSTR pszAttributeName
  116. )
  117. {
  118. RRETURN (E_NOTIMPL);
  119. }
  120. HRESULT
  121. CNDSGenObject::EnumClasses(
  122. LPWSTR * ppszClassNames,
  123. DWORD dwNumClasses,
  124. PADS_CLASS_DEF * ppClassDefinition,
  125. DWORD * pdwNumClasses
  126. )
  127. {
  128. RRETURN (E_NOTIMPL);
  129. }
  130. HRESULT
  131. CNDSGenObject::CreateClassDefinition(
  132. LPWSTR pszClassName,
  133. PADS_CLASS_DEF pClassDefinition
  134. )
  135. {
  136. RRETURN (E_NOTIMPL);
  137. }
  138. HRESULT
  139. CNDSGenObject::WriteClassDefinition(
  140. LPWSTR pszClassName,
  141. PADS_CLASS_DEF pClassDefinition
  142. )
  143. {
  144. RRETURN (E_NOTIMPL);
  145. }
  146. HRESULT
  147. CNDSGenObject::DeleteClassDefinition(
  148. LPWSTR pszClassName
  149. )
  150. {
  151. RRETURN (E_NOTIMPL);
  152. }
  153. HRESULT
  154. ComputeADsAttrDefBufferSize(
  155. LPNDS_ATTR_DEF pAttributes,
  156. DWORD dwNumAttributes,
  157. PDWORD pdwSize
  158. )
  159. {
  160. DWORD i = 0;
  161. DWORD dwSize = 0;
  162. dwSize = sizeof(ADS_ATTR_DEF) * dwNumAttributes;
  163. for (i = 0; i < dwNumAttributes; i++)
  164. dwSize += (wcslen(pAttributes[i].szAttributeName) + 1)*sizeof(WCHAR);
  165. *pdwSize = dwSize;
  166. RRETURN(S_OK);
  167. }