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.

171 lines
4.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: dsgbl.hxx
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "activeds.h"
  11. #include "adsi.h"
  12. #define RPCENTRYABSTRACT L"rpcEntry"
  13. #define RPCSERVERCONTAINERCLASS L"rpcServer"
  14. #define RPCPROFILECONTAINERCLASS L"rpcProfile"
  15. #define RPCGROUPCLASS L"rpcGroup"
  16. #define RPCSERVERELEMENTCLASS L"rpcServerElement"
  17. #define RPCPROFILEELEMENTCLASS L"rpcProfileElement"
  18. //------------------properties
  19. #define OBJECTID L"rpcNsObjectID"
  20. #define GROUP L"rpcNsGroup"
  21. #define PRIORITY L"rpcNsPriority"
  22. #define PROFILE L"rpcNsProfileEntry"
  23. #define INTERFACEID L"rpcNsInterfaceId"
  24. #define ANNOTATION L"rpcNsAnnotation"
  25. #define CODESET L"rpcNsCodeset"
  26. #define BINDINGS L"rpcNsBindings"
  27. #define TRANSFERSYNTAX L"rpcNsTransferSyntax"
  28. #define CLASSNAME L"objectClass"
  29. //-----------draft specification
  30. #define DESCRIPTION L"description"
  31. #define CREATED_DESCRIPTION L"Created Entry"
  32. #define NT4COMPATIBILITY_FLAG L"nameServiceFlags"
  33. #define DISTINGUISHEDNAME L"distinguishedName"
  34. #define RPCSUBCONTAINER L"CN=RpcServices,CN=System,"
  35. #define DEFAULTNAMINGCONTEXT L"defaultNamingContext"
  36. #define ROOTCONTAINER L"rootdse"
  37. #define RPCCONTAINERPREFIX L"LDAP://"
  38. #define RPCCONTAINERPREFIXLEN 7
  39. #define MAX_DS_QUERY_LEN 500
  40. // extern int fTriedConnectingToDS;
  41. DWORD RemapErrorCode(HRESULT hr);
  42. #define STRINGGUIDLEN 36
  43. #define STRINGGUIDVERSIONLEN 46
  44. #define STRINGMAJVERSIONLEN 41 // length till major version length
  45. typedef WCHAR STRINGGUID [STRINGGUIDLEN+1];
  46. typedef WCHAR STRINGGUIDVERSION [STRINGGUIDVERSIONLEN+1];
  47. int UuidToStringEx(UUID *Uuid, WCHAR *StringUuid);
  48. // converting to and from syntax identifiers
  49. BOOL SyntaxIdToString(RPC_SYNTAX_IDENTIFIER &SynId, WCHAR *StringSynId);
  50. BOOL SyntaxIdFromString(RPC_SYNTAX_IDENTIFIER &SynId, WCHAR *StringSynId);
  51. DWORD GetPropertyFromAttr(ADS_ATTR_INFO *pattr, DWORD cNum, WCHAR *szProperty);
  52. // ADS_ATTR_INFO structure is returned in GetObjectAttributes.
  53. // this is the same structure as columns but has different
  54. // fields and has unfortunately 1 unused different member.
  55. // this doesn't actually copy and hence should be freed if required
  56. // by the user but allocates an array of req'd size in case
  57. // of Unpack*Arr
  58. // pack functions are in dsedit.cxx
  59. template <class AttrOrCol>
  60. void UnpackStrArrFrom(AttrOrCol AorC, WCHAR ***ppszAttr, DWORD *num)
  61. {
  62. DWORD i;
  63. *num = AorC.dwNumValues;
  64. *ppszAttr = new LPWSTR[*num];
  65. if (!(*ppszAttr)) {
  66. *num = 0;
  67. return;
  68. }
  69. for (i = 0; (i < (*num)); i++)
  70. (*ppszAttr)[i] = AorC.pADsValues[i].DNString;
  71. }
  72. template <class AttrOrCol>
  73. void UnpackIntArrFrom(AttrOrCol AorC, int **pAttr, DWORD *num)
  74. {
  75. DWORD i;
  76. ASSERT(AorC.dwADsType == ADSTYPE_INTEGER, L"Error:: Type is not integer\n");
  77. *num = AorC.dwNumValues;
  78. *pAttr = new int[*num];
  79. if (!(*pAttr)) {
  80. *num = 0;
  81. return;
  82. }
  83. for (i = 0; (i < (*num)); i++)
  84. (*pAttr)[i] = AorC.pADsValues[i].Integer;
  85. }
  86. template <class AttrOrCol>
  87. WCHAR *UnpackStrFrom(AttrOrCol AorC)
  88. {
  89. ASSERT(AorC.dwNumValues <= 1, L"Error:: Number of string values is greater than 1\n");
  90. if (AorC.dwNumValues)
  91. return AorC.pADsValues[0].DNString;
  92. else
  93. return NULL;
  94. }
  95. template <class AttrOrCol>
  96. int UnpackIntFrom(AttrOrCol AorC)
  97. {
  98. ASSERT(AorC.dwADsType == ADSTYPE_INTEGER, L"Error:: Type is not integer\n");
  99. ASSERT(AorC.dwNumValues <= 1, L"Error:: Number of integer values is greater than 1\n");
  100. if (AorC.dwNumValues)
  101. return AorC.pADsValues[0].Integer;
  102. else
  103. return 0;
  104. }
  105. HRESULT GetRpcContainerForDomain(WCHAR *szDomain, WCHAR **szRpcContainerDN, WCHAR **szDomainDns);
  106. HRESULT GetDefaultRpcContainer(DSROLE_PRIMARY_DOMAIN_INFO_BASIC dsrole,
  107. WCHAR **szRootPath);
  108. class CServerEntry;
  109. class CDSQry{
  110. private:
  111. HANDLE hDSObject;
  112. ADS_SEARCH_HANDLE hSearchHandle;
  113. public:
  114. CDSQry(WCHAR *filter, HRESULT *phr);
  115. ~CDSQry();
  116. CServerEntry *next();
  117. };
  118. // dsgbl.hxx
  119. // an encapsulation of a DS binding handle, that will get destroyed.
  120. class CDSHandle {
  121. private:
  122. HANDLE hDSObject;
  123. public:
  124. CDSHandle(STRING_T szDomainNameDns, STRING_T szRpcContainer);
  125. ~CDSHandle();
  126. };