Blame view
sources/apps/user_ldap/lib/ildapwrapper.php
6.51 KB
|
31b7f2792
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<?php
/**
* ownCloud – LDAP Wrapper Interface
*
* @author Arthur Schiwon
* @copyright 2013 Arthur Schiwon blizzz@owncloud.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\user_ldap\lib;
interface ILDAPWrapper {
//LDAP functions in use
/**
|
|
6d9380f96
|
31 32 33 34 35 |
* Bind to LDAP directory * @param resource $link LDAP link resource * @param string $dn an RDN to log in with * @param string $password the password * @return bool true on success, false otherwise |
|
31b7f2792
|
36 37 38 39 40 41 |
* * with $dn and $password as null a anonymous bind is attempted. */ public function bind($link, $dn, $password); /** |
|
6d9380f96
|
42 43 44 45 |
* connect to an LDAP server * @param string $host The host to connect to * @param string $port The port to connect to * @return mixed a link resource on success, otherwise false |
|
31b7f2792
|
46 47 48 49 |
*/ public function connect($host, $port); /** |
|
6d9380f96
|
50 51 52 53 54 55 |
* Send LDAP pagination control * @param resource $link LDAP link resource * @param int $pageSize number of results per page * @param bool $isCritical Indicates whether the pagination is critical of not. * @param array $cookie structure sent by LDAP server * @return bool true on success, false otherwise |
|
31b7f2792
|
56 |
*/ |
|
6d9380f96
|
57 |
public function controlPagedResult($link, $pageSize, $isCritical, $cookie); |
|
31b7f2792
|
58 59 |
/** |
|
6d9380f96
|
60 61 62 63 64 |
* Retrieve the LDAP pagination cookie * @param resource $link LDAP link resource * @param resource $result LDAP result resource * @param string $cookie structure sent by LDAP server * @return bool true on success, false otherwise |
|
31b7f2792
|
65 66 67 68 69 70 |
* * Corresponds to ldap_control_paged_result_response */ public function controlPagedResultResponse($link, $result, &$cookie); /** |
|
6d9380f96
|
71 72 73 74 |
* Count the number of entries in a search * @param resource $link LDAP link resource * @param resource $result LDAP result resource * @return int|false number of results on success, false otherwise |
|
31b7f2792
|
75 76 77 78 |
*/ public function countEntries($link, $result); /** |
|
6d9380f96
|
79 80 81 |
* Return the LDAP error number of the last LDAP command * @param resource $link LDAP link resource * @return string error message as string |
|
31b7f2792
|
82 83 84 85 |
*/ public function errno($link); /** |
|
6d9380f96
|
86 87 88 |
* Return the LDAP error message of the last LDAP command * @param resource $link LDAP link resource * @return int error code as integer |
|
31b7f2792
|
89 90 91 92 |
*/ public function error($link); /** |
|
6d9380f96
|
93 94 95 96 97 98 99 100 101 102 103 104 105 |
* Splits DN into its component parts * @param string $dn * @param int @withAttrib * @return array|false * @link http://www.php.net/manual/en/function.ldap-explode-dn.php */ public function explodeDN($dn, $withAttrib); /** * Return first result id * @param resource $link LDAP link resource * @param resource $result LDAP result resource * @return Resource an LDAP search result resource |
|
31b7f2792
|
106 107 108 109 |
* */ public function firstEntry($link, $result); /** |
|
6d9380f96
|
110 111 112 |
* Get attributes from a search result entry * @param resource $link LDAP link resource * @param resource $result LDAP result resource |
|
31b7f2792
|
113 114 115 116 117 |
* @return array containing the results, false on error * */ public function getAttributes($link, $result); /** |
|
6d9380f96
|
118 119 120 |
* Get the DN of a result entry * @param resource $link LDAP link resource * @param resource $result LDAP result resource |
|
31b7f2792
|
121 122 123 124 125 |
* @return string containing the DN, false on error */ public function getDN($link, $result); /** |
|
6d9380f96
|
126 127 128 |
* Get all result entries * @param resource $link LDAP link resource * @param resource $result LDAP result resource |
|
31b7f2792
|
129 130 131 132 133 |
* @return array containing the results, false on error */ public function getEntries($link, $result); /** |
|
6d9380f96
|
134 135 136 137 |
* Return next result id * @param resource $link LDAP link resource * @param resource $result LDAP entry result resource * @return resource an LDAP search result resource |
|
31b7f2792
|
138 139 140 141 |
* */ public function nextEntry($link, $result); /** |
|
6d9380f96
|
142 143 144 145 146 147 |
* Read an entry * @param resource $link LDAP link resource * @param array $baseDN The DN of the entry to read from * @param string $filter An LDAP filter * @param array $attr array of the attributes to read * @return resource an LDAP search result resource |
|
31b7f2792
|
148 149 150 151 |
*/ public function read($link, $baseDN, $filter, $attr); /** |
|
6d9380f96
|
152 153 154 155 156 157 158 159 |
* Search LDAP tree * @param resource $link LDAP link resource * @param string $baseDN The DN of the entry to read from * @param string $filter An LDAP filter * @param array $attr array of the attributes to read * @param int $attrsOnly optional, 1 if only attribute types shall be returned * @param int $limit optional, limits the result entries * @return resource|false an LDAP search result resource, false on error |
|
31b7f2792
|
160 |
*/ |
|
6d9380f96
|
161 |
public function search($link, $baseDN, $filter, $attr, $attrsOnly = 0, $limit = 0); |
|
31b7f2792
|
162 163 |
/** |
|
6d9380f96
|
164 165 166 167 168 |
* Sets the value of the specified option to be $value * @param resource $link LDAP link resource * @param string $option a defined LDAP Server option * @param int $value the new value for the option * @return bool true on success, false otherwise |
|
31b7f2792
|
169 170 171 172 |
*/ public function setOption($link, $option, $value); /** |
|
6d9380f96
|
173 174 175 |
* establish Start TLS * @param resource $link LDAP link resource * @return bool true on success, false otherwise |
|
31b7f2792
|
176 177 178 179 |
*/ public function startTls($link); /** |
|
6d9380f96
|
180 181 182 183 |
* Sort the result of a LDAP search * @param resource $link LDAP link resource * @param resource $result LDAP result resource * @param string $sortFilter attribute to use a key in sort |
|
31b7f2792
|
184 |
*/ |
|
6d9380f96
|
185 |
public function sort($link, $result, $sortFilter); |
|
31b7f2792
|
186 187 |
/** |
|
6d9380f96
|
188 189 190 |
* Unbind from LDAP directory * @param resource $link LDAP link resource * @return bool true on success, false otherwise |
|
31b7f2792
|
191 192 |
*/ public function unbind($link); |
|
6d9380f96
|
193 |
//additional required methods in ownCloud |
|
31b7f2792
|
194 195 |
/** |
|
6d9380f96
|
196 197 |
* Checks whether the server supports LDAP * @return bool true if it the case, false otherwise |
|
31b7f2792
|
198 199 200 201 |
* */ public function areLDAPFunctionsAvailable(); /** |
|
6d9380f96
|
202 203 |
* Checks whether PHP supports LDAP Paged Results * @return bool true if it the case, false otherwise |
|
31b7f2792
|
204 205 206 207 |
* */ public function hasPagedResultSupport(); /** |
|
6d9380f96
|
208 209 210 |
* Checks whether the submitted parameter is a resource * @param resource $resource the resource variable to check * @return bool true if it is a resource, false otherwise |
|
31b7f2792
|
211 212 213 214 |
*/ public function isResource($resource); } |