IAdapter.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2020 Arthur Schiwon <blizzz@arthur-schiwon.de>
  5. *
  6. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCA\User_LDAP\PagedResults;
  25. interface IAdapter {
  26. /**
  27. * Methods for initiating Paged Results Control
  28. */
  29. /**
  30. * The adapter receives paged result parameters from the client. It may
  31. * store the parameters for later use.
  32. */
  33. public function setRequestParameters($link, int $pageSize, bool $isCritical): void;
  34. /**
  35. * The adapter is asked for an function that is being explicitly called to
  36. * send the control parameters to LDAP. If not function has to be called,
  37. * null shall be returned.
  38. *
  39. * It will used by the callee for diagnosis and error handling.
  40. */
  41. public function getRequestCallFunc(): ?string;
  42. /**
  43. * The adapter is asked to provide the arguments it would pass to the
  44. * function returned by getRequestCallFunc(). If none shall be called, an
  45. * empty array should be returned.
  46. *
  47. * It will used by the callee for diagnosis and error handling.
  48. */
  49. public function getRequestCallArgs($link): array;
  50. /**
  51. * The adapter is asked to do the necessary calls to LDAP, if
  52. * getRequestCallFunc returned a function. If none, it will not be called
  53. * so the return value is best set to false. Otherwise it shall respond
  54. * whether setting the controls was successful.
  55. */
  56. public function requestCall($link): bool;
  57. /**
  58. * The adapter shall report which PHP function will be called to process
  59. * the paged results call
  60. *
  61. * It will used by the callee for diagnosis and error handling.
  62. */
  63. public function getResponseCallFunc(): string;
  64. /**
  65. * The adapter shall report with arguments will be provided to the LDAP
  66. * function it will call
  67. *
  68. * It will used by the callee for diagnosis and error handling.
  69. */
  70. public function getResponseCallArgs(array $originalArgs): array;
  71. /**
  72. * the adapter should do it's LDAP function call and return success state
  73. *
  74. * @param resource|\LDAP\Connection $link LDAP resource
  75. * @return bool
  76. */
  77. public function responseCall($link): bool;
  78. /**
  79. * The adapter receives the parameters that were passed to a search
  80. * operation. Typically it wants to save the them for the call proper later
  81. * on.
  82. */
  83. public function setSearchArgs(
  84. $link,
  85. string $baseDN,
  86. string $filter,
  87. array $attr,
  88. int $attrsOnly,
  89. int $limit
  90. ): void;
  91. /**
  92. * The adapter shall report which arguments shall be passed to the
  93. * ldap_search function.
  94. */
  95. public function getSearchArgs($link): array;
  96. /**
  97. * The adapter receives the parameters that were passed to a read
  98. * operation. Typically it wants to save the them for the call proper later
  99. * on.
  100. */
  101. public function setReadArgs($link, string $baseDN, string $filter, array $attr): void;
  102. /**
  103. * The adapter shall report which arguments shall be passed to the
  104. * ldap_read function.
  105. */
  106. public function getReadArgs($link): array;
  107. /**
  108. * Returns the current paged results cookie
  109. *
  110. * @param resource|\LDAP\Connection $link LDAP resource
  111. * @return string
  112. */
  113. public function getCookie($link): string;
  114. }