ILDAPProvider.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. *
  4. * @copyright Copyright (c) 2016, Roger Szabo (roger.szabo@web.de)
  5. *
  6. * @license GNU AGPL version 3 or any later version
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. namespace OCP\LDAP;
  23. /**
  24. * Interface ILDAPProvider
  25. *
  26. * @package OCP\LDAP
  27. * @since 11.0.0
  28. */
  29. interface ILDAPProvider {
  30. /**
  31. * Translate a user id to LDAP DN.
  32. * @param string $uid user id
  33. * @return string
  34. * @since 11.0.0
  35. */
  36. public function getUserDN($uid);
  37. /**
  38. * Translate a LDAP DN to an internal user name.
  39. * @param string $dn LDAP DN
  40. * @return string with the internal user name
  41. * @throws \Exception if translation was unsuccessful
  42. * @since 11.0.0
  43. */
  44. public function getUserName($dn);
  45. /**
  46. * Convert a stored DN so it can be used as base parameter for LDAP queries.
  47. * @param string $dn the DN
  48. * @return string
  49. * @since 11.0.0
  50. */
  51. public function DNasBaseParameter($dn);
  52. /**
  53. * Sanitize a DN received from the LDAP server.
  54. * @param array $dn the DN in question
  55. * @return array the sanitized DN
  56. * @since 11.0.0
  57. */
  58. public function sanitizeDN($dn);
  59. /**
  60. * Return a new LDAP connection resource for the specified user.
  61. * @param string $uid user id
  62. * @return resource of the LDAP connection
  63. * @since 11.0.0
  64. */
  65. public function getLDAPConnection($uid);
  66. /**
  67. * Get the LDAP base for users.
  68. * @param string $uid user id
  69. * @return string the base for users
  70. * @throws \Exception if user id was not found in LDAP
  71. * @since 11.0.0
  72. */
  73. public function getLDAPBaseUsers($uid);
  74. /**
  75. * Get the LDAP base for groups.
  76. * @param string $uid user id
  77. * @return string the base for groups
  78. * @throws \Exception if user id was not found in LDAP
  79. * @since 11.0.0
  80. */
  81. public function getLDAPBaseGroups($uid);
  82. /**
  83. * Check whether a LDAP DN exists
  84. * @param string $dn LDAP DN
  85. * @return bool whether the DN exists
  86. * @since 11.0.0
  87. */
  88. public function dnExists($dn);
  89. /**
  90. * Clear the cache if a cache is used, otherwise do nothing.
  91. * @param string $uid user id
  92. * @since 11.0.0
  93. */
  94. public function clearCache($uid);
  95. }