ILDAPProvider.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCP\LDAP;
  7. /**
  8. * Interface ILDAPProvider
  9. *
  10. * @since 11.0.0
  11. */
  12. interface ILDAPProvider {
  13. /**
  14. * Translate a user id to LDAP DN.
  15. * @param string $uid user id
  16. * @return string
  17. * @since 11.0.0
  18. */
  19. public function getUserDN($uid);
  20. /**
  21. * Translate a group id to LDAP DN.
  22. * @param string $gid group id
  23. * @return string
  24. * @since 13.0.0
  25. */
  26. public function getGroupDN($gid);
  27. /**
  28. * Translate a LDAP DN to an internal user name.
  29. * @param string $dn LDAP DN
  30. * @return string with the internal user name
  31. * @throws \Exception if translation was unsuccessful
  32. * @since 11.0.0
  33. */
  34. public function getUserName($dn);
  35. /**
  36. * Convert a stored DN so it can be used as base parameter for LDAP queries.
  37. * @param string $dn the DN
  38. * @return string
  39. * @since 11.0.0
  40. */
  41. public function DNasBaseParameter($dn);
  42. /**
  43. * Sanitize a DN received from the LDAP server.
  44. * @param array $dn the DN in question
  45. * @return array the sanitized DN
  46. * @since 11.0.0
  47. */
  48. public function sanitizeDN($dn);
  49. /**
  50. * Return a new LDAP connection resource for the specified user.
  51. * @param string $uid user id
  52. * @return \LDAP\Connection|resource
  53. * @since 11.0.0
  54. */
  55. public function getLDAPConnection($uid);
  56. /**
  57. * Return a new LDAP connection resource for the specified group.
  58. * @param string $gid group id
  59. * @return \LDAP\Connection|resource
  60. * @since 13.0.0
  61. */
  62. public function getGroupLDAPConnection($gid);
  63. /**
  64. * Get the LDAP base for users.
  65. * @param string $uid user id
  66. * @return string the base for users
  67. * @throws \Exception if user id was not found in LDAP
  68. * @since 11.0.0
  69. */
  70. public function getLDAPBaseUsers($uid);
  71. /**
  72. * Get the LDAP base for groups.
  73. * @param string $uid user id
  74. * @return string the base for groups
  75. * @throws \Exception if user id was not found in LDAP
  76. * @since 11.0.0
  77. */
  78. public function getLDAPBaseGroups($uid);
  79. /**
  80. * Check whether a LDAP DN exists
  81. * @param string $dn LDAP DN
  82. * @return bool whether the DN exists
  83. * @since 11.0.0
  84. */
  85. public function dnExists($dn);
  86. /**
  87. * Clear the cache if a cache is used, otherwise do nothing.
  88. * @param string $uid user id
  89. * @since 11.0.0
  90. */
  91. public function clearCache($uid);
  92. /**
  93. * Clear the cache if a cache is used, otherwise do nothing.
  94. * @param string $gid group id
  95. * @since 13.0.0
  96. */
  97. public function clearGroupCache($gid);
  98. /**
  99. * Get the LDAP attribute name for the user's display name
  100. * @param string $uid user id
  101. * @return string the display name field
  102. * @throws \Exception if user id was not found in LDAP
  103. * @since 12.0.0
  104. */
  105. public function getLDAPDisplayNameField($uid);
  106. /**
  107. * Get the LDAP attribute name for the email
  108. * @param string $uid user id
  109. * @return string the email field
  110. * @throws \Exception if user id was not found in LDAP
  111. * @since 12.0.0
  112. */
  113. public function getLDAPEmailField($uid);
  114. /**
  115. * Get the LDAP attribute name for the type of association between users and groups
  116. * @param string $gid group id
  117. * @return string the configuration, one of: 'memberUid', 'uniqueMember', 'member', 'gidNumber', ''
  118. * @throws \Exception if group id was not found in LDAP
  119. * @since 13.0.0
  120. */
  121. public function getLDAPGroupMemberAssoc($gid);
  122. /**
  123. * Get an LDAP attribute for a nextcloud user
  124. *
  125. * @throws \Exception if user id was not found in LDAP
  126. * @since 21.0.0
  127. */
  128. public function getUserAttribute(string $uid, string $attribute): ?string;
  129. /**
  130. * Get a multi-value LDAP attribute for a nextcloud user
  131. *
  132. * @throws \Exception if user id was not found in LDAP
  133. * @since 22.0.0
  134. */
  135. public function getMultiValueUserAttribute(string $uid, string $attribute): array;
  136. }