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.

160 lines
4.3 KiB

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