ILDAPProvider.php 4.2 KB

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