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.

153 lines
4.4 KiB

  1. /* ----------------------------------------------------------------------
  2. Module: ULS.DLL (Service Provider)
  3. File: spserver.cpp
  4. Content: This file contains the server and its authentication.
  5. History:
  6. 10/15/96 Chu, Lon-Chan [lonchanc]
  7. Created.
  8. Copyright (c) Microsoft Corporation 1996-1997
  9. ---------------------------------------------------------------------- */
  10. #include "ulsp.h"
  11. #include "spinc.h"
  12. BOOL IlsSameServerInfo ( const SERVER_INFO *p1, const SERVER_INFO *p2 )
  13. {
  14. return (p1->uTimeoutInSecond == p2->uTimeoutInSecond &&
  15. p1->AuthMethod == p2->AuthMethod &&
  16. My_lstrcmpi (p1->pszServerName, p2->pszServerName) == 0 &&
  17. My_lstrcmpi (p1->pszLogonName, p2->pszLogonName) == 0 &&
  18. My_lstrcmpi (p1->pszLogonPassword, p2->pszLogonPassword) == 0 &&
  19. My_lstrcmpi (p1->pszDomain, p2->pszDomain) == 0 &&
  20. My_lstrcmpi (p1->pszBaseDN, p2->pszBaseDN) == 0 &&
  21. My_lstrcmpi (p1->pszCredential, p2->pszCredential) == 0);
  22. }
  23. HRESULT IlsCopyServerInfo ( SERVER_INFO *pDst, const SERVER_INFO *pSrc )
  24. {
  25. MyAssert (pDst != NULL && pSrc != NULL);
  26. SERVER_INFO si;
  27. ZeroMemory (&si, sizeof (si));
  28. si.uTimeoutInSecond = pSrc->uTimeoutInSecond;
  29. si.AuthMethod = pSrc->AuthMethod;
  30. si.pszServerName = My_strdup (pSrc->pszServerName);
  31. si.pszLogonName = My_strdup (pSrc->pszLogonName);
  32. si.pszLogonPassword = My_strdup (pSrc->pszLogonPassword);
  33. si.pszDomain = My_strdup (pSrc->pszDomain);
  34. si.pszCredential = My_strdup (pSrc->pszCredential);
  35. si.pszBaseDN = My_strdup (pSrc->pszBaseDN);
  36. if ((pSrc->pszServerName != NULL && si.pszServerName == NULL) ||
  37. (pSrc->pszLogonName != NULL && si.pszLogonName == NULL) ||
  38. (pSrc->pszLogonPassword != NULL && si.pszLogonPassword == NULL) ||
  39. (pSrc->pszDomain != NULL && si.pszDomain == NULL) ||
  40. (pSrc->pszCredential != NULL && si.pszCredential == NULL) ||
  41. (pSrc->pszBaseDN != NULL && si.pszBaseDN == NULL)
  42. )
  43. {
  44. IlsFreeServerInfo (&si);
  45. return ILS_E_MEMORY;
  46. }
  47. *pDst = si;
  48. return S_OK;
  49. }
  50. VOID IlsFreeServerInfo ( SERVER_INFO *psi )
  51. {
  52. if (psi != NULL)
  53. {
  54. MemFree (psi->pszServerName);
  55. MemFree (psi->pszLogonName);
  56. MemFree (psi->pszLogonPassword);
  57. MemFree (psi->pszDomain);
  58. MemFree (psi->pszCredential);
  59. MemFree (psi->pszBaseDN);
  60. ZeroMemory (psi, sizeof (*psi));
  61. }
  62. }
  63. ULONG IlsGetLinearServerInfoSize ( const SERVER_INFO *psi )
  64. {
  65. ULONG cbSize = sizeof (SERVER_INFO);
  66. cbSize += (My_lstrlen (psi->pszServerName) + 1) * sizeof (TCHAR);
  67. cbSize += (My_lstrlen (psi->pszLogonName) + 1) * sizeof (TCHAR);
  68. cbSize += (My_lstrlen (psi->pszLogonPassword) + 1) * sizeof (TCHAR);
  69. cbSize += (My_lstrlen (psi->pszDomain) + 1) * sizeof (TCHAR);
  70. cbSize += (My_lstrlen (psi->pszCredential) + 1) * sizeof (TCHAR);
  71. cbSize += (My_lstrlen (psi->pszBaseDN) + 1) * sizeof (TCHAR);
  72. return cbSize;
  73. }
  74. VOID IlsLinearizeServerInfo ( BYTE *pData, const SERVER_INFO *pSrc )
  75. {
  76. SERVER_INFO *p = (SERVER_INFO *) pData;
  77. pData = (BYTE *) (p + 1);
  78. CopyMemory (p, pSrc, sizeof (SERVER_INFO));
  79. if (pSrc->pszServerName != NULL)
  80. {
  81. p->pszServerName = (TCHAR *) pData;
  82. My_lstrcpy ((TCHAR *) pData, pSrc->pszServerName);
  83. pData += (lstrlen (pSrc->pszServerName) + 1) * sizeof (TCHAR);
  84. }
  85. if (pSrc->pszLogonName != NULL)
  86. {
  87. p->pszLogonName = (TCHAR *) pData;
  88. My_lstrcpy ((TCHAR *) pData, pSrc->pszLogonName);
  89. pData += (lstrlen (pSrc->pszLogonName) + 1) * sizeof (TCHAR);
  90. }
  91. if (pSrc->pszLogonPassword != NULL)
  92. {
  93. p->pszLogonPassword = (TCHAR *) pData;
  94. My_lstrcpy ((TCHAR *) pData, pSrc->pszLogonPassword);
  95. pData += (lstrlen (pSrc->pszLogonPassword) + 1) * sizeof (TCHAR);
  96. }
  97. if (pSrc->pszDomain != NULL)
  98. {
  99. p->pszDomain = (TCHAR *) pData;
  100. My_lstrcpy ((TCHAR *) pData, pSrc->pszDomain);
  101. pData += (lstrlen (pSrc->pszDomain) + 1) * sizeof (TCHAR);
  102. }
  103. if (pSrc->pszCredential != NULL)
  104. {
  105. p->pszCredential = (TCHAR *) pData;
  106. My_lstrcpy ((TCHAR *) pData, pSrc->pszCredential);
  107. pData += (lstrlen (pSrc->pszCredential) + 1) * sizeof (TCHAR);
  108. }
  109. if (pSrc->pszBaseDN != NULL)
  110. {
  111. p->pszBaseDN = (TCHAR *) pData;
  112. My_lstrcpy ((TCHAR *) pData, pSrc->pszBaseDN);
  113. pData += (lstrlen (pSrc->pszBaseDN) + 1) * sizeof (TCHAR);
  114. }
  115. }
  116. HRESULT IlsFillDefServerInfo ( SERVER_INFO *p, TCHAR *pszServerName )
  117. {
  118. ZeroMemory (p, sizeof (*p));
  119. p->pszServerName = My_strdup (pszServerName);
  120. return ((p->pszServerName != NULL) ? S_OK : ILS_E_MEMORY);
  121. }