ILDAPProvider.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, Roger Szabo (roger.szabo@web.de)
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author blizzz <blizzz@arthur-schiwon.de>
  7. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  8. * @author Robin Appelman <robin@icewind.nl>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. * @author Roger Szabo <roger.szabo@web.de>
  11. * @author root <root@localhost.localdomain>
  12. * @author Vinicius Cubas Brand <vinicius@eita.org.br>
  13. *
  14. * @license GNU AGPL version 3 or any later version
  15. *
  16. * This program is free software: you can redistribute it and/or modify
  17. * it under the terms of the GNU Affero General Public License as
  18. * published by the Free Software Foundation, either version 3 of the
  19. * License, or (at your option) any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU Affero General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Affero General Public License
  27. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  28. *
  29. */
  30. namespace OCP\LDAP;
  31. /**
  32. * Interface ILDAPProvider
  33. *
  34. * @since 11.0.0
  35. */
  36. interface ILDAPProvider {
  37. /**
  38. * Translate a user id to LDAP DN.
  39. * @param string $uid user id
  40. * @return string
  41. * @since 11.0.0
  42. */
  43. public function getUserDN($uid);
  44. /**
  45. * Translate a group id to LDAP DN.
  46. * @param string $gid group id
  47. * @return string
  48. * @since 13.0.0
  49. */
  50. public function getGroupDN($gid);
  51. /**
  52. * Translate a LDAP DN to an internal user name.
  53. * @param string $dn LDAP DN
  54. * @return string with the internal user name
  55. * @throws \Exception if translation was unsuccessful
  56. * @since 11.0.0
  57. */
  58. public function getUserName($dn);
  59. /**
  60. * Convert a stored DN so it can be used as base parameter for LDAP queries.
  61. * @param string $dn the DN
  62. * @return string
  63. * @since 11.0.0
  64. */
  65. public function DNasBaseParameter($dn);
  66. /**
  67. * Sanitize a DN received from the LDAP server.
  68. * @param array $dn the DN in question
  69. * @return array the sanitized DN
  70. * @since 11.0.0
  71. */
  72. public function sanitizeDN($dn);
  73. /**
  74. * Return a new LDAP connection resource for the specified user.
  75. * @param string $uid user id
  76. * @return resource of the LDAP connection
  77. * @since 11.0.0
  78. */
  79. public function getLDAPConnection($uid);
  80. /**
  81. * Return a new LDAP connection resource for the specified group.
  82. * @param string $gid group id
  83. * @return resource of the LDAP connection
  84. * @since 13.0.0
  85. */
  86. public function getGroupLDAPConnection($gid);
  87. /**
  88. * Get the LDAP base for users.
  89. * @param string $uid user id
  90. * @return string the base for users
  91. * @throws \Exception if user id was not found in LDAP
  92. * @since 11.0.0
  93. */
  94. public function getLDAPBaseUsers($uid);
  95. /**
  96. * Get the LDAP base for groups.
  97. * @param string $uid user id
  98. * @return string the base for groups
  99. * @throws \Exception if user id was not found in LDAP
  100. * @since 11.0.0
  101. */
  102. public function getLDAPBaseGroups($uid);
  103. /**
  104. * Check whether a LDAP DN exists
  105. * @param string $dn LDAP DN
  106. * @return bool whether the DN exists
  107. * @since 11.0.0
  108. */
  109. public function dnExists($dn);
  110. /**
  111. * Clear the cache if a cache is used, otherwise do nothing.
  112. * @param string $uid user id
  113. * @since 11.0.0
  114. */
  115. public function clearCache($uid);
  116. /**
  117. * Clear the cache if a cache is used, otherwise do nothing.
  118. * @param string $gid group id
  119. * @since 13.0.0
  120. */
  121. public function clearGroupCache($gid);
  122. /**
  123. * Get the LDAP attribute name for the user's display name
  124. * @param string $uid user id
  125. * @return string the display name field
  126. * @throws \Exception if user id was not found in LDAP
  127. * @since 12.0.0
  128. */
  129. public function getLDAPDisplayNameField($uid);
  130. /**
  131. * Get the LDAP attribute name for the email
  132. * @param string $uid user id
  133. * @return string the email field
  134. * @throws \Exception if user id was not found in LDAP
  135. * @since 12.0.0
  136. */
  137. public function getLDAPEmailField($uid);
  138. /**
  139. * Get the LDAP attribute name for the type of association betweeen users and groups
  140. * @param string $gid group id
  141. * @return string the configuration, one of: 'memberUid', 'uniqueMember', 'member', 'gidNumber', ''
  142. * @throws \Exception if group id was not found in LDAP
  143. * @since 13.0.0
  144. */
  145. public function getLDAPGroupMemberAssoc($gid);
  146. /**
  147. * Get an LDAP attribute for a nextcloud user
  148. *
  149. * @throws \Exception if user id was not found in LDAP
  150. * @since 21.0.0
  151. */
  152. public function getUserAttribute(string $uid, string $attribute): ?string;
  153. /**
  154. * Get a multi-value LDAP attribute for a nextcloud user
  155. *
  156. * @throws \Exception if user id was not found in LDAP
  157. * @since 22.0.0
  158. */
  159. public function getMultiValueUserAttribute(string $uid, string $attribute): array;
  160. }