Changeset 1559
- Timestamp:
- 04/18/08 15:54:50 (1 month ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/peer/ldap/stubLDAPURL.php
r1556 r1559 63 63 * @return stubLDAPURL 64 64 * @throws stubMalformedURLException 65 *66 65 */ 67 66 public static function fromString($urlString) … … 93 92 // check scheme 94 93 if($this->url['scheme'] !== 'ldap' && $this->url['scheme'] !== 'ldaps') { 95 return false;96 }97 98 // check port99 if($this->url['scheme'] === 'ldap' && $this->url['port'] !== 389) {100 return false;101 } else if($this->url['scheme'] === 'ldaps' && $this->url['port'] !== 636) {102 94 return false; 103 95 } … … 134 126 135 127 /** 136 * Gets the base dn (distinguished name) 128 * Gets the base dn (distinguished name). 137 129 * 138 130 * @return string … … 143 135 return null; 144 136 } 145 137 146 138 return $this->url['base_dn']; 147 139 } 148 140 149 141 /** 150 * Gets the base dn (distinguished name) 142 * Changes the originally used base dn (distinguished name). 143 * 144 * @param string $newBaseDn 145 */ 146 public function setBaseDn($newBaseDn) 147 { 148 $this->url['base_dn'] = $newBaseDn; 149 } 150 151 /** 152 * Gets the base dn (distinguished name). 151 153 * 152 154 * @return string … … 157 159 return null; 158 160 } 159 161 160 162 return $this->url['base_dn']; 161 163 } … … 164 166 * Checks if query string was provided. 165 167 * 166 * query:= attributes, scope and filter168 * query:= {attributes}?{scope}?{filter}' 167 169 * 168 170 * @return boolean … … 175 177 /** 176 178 * Gets the value of an optional parameter from the query string. 177 * 178 * parameter:= attributes|scope|filter179 * 180 * There's a difference between a parameter explicity not set (returns '')181 * and the param not set in the query string (returns null or defaultValue)182 * or no query string at all (returns null or defaultvalue).179 * Valid LDAP parameters are 'attributes', 'scope' or 'filter'. 180 * 181 * If they were not set before the default values are: 182 * attributes = '' 183 * scope = 'base' 184 * filters = 'objectClass=*' 183 185 * 184 186 * possibilities for query string: … … 191 193 * ? ?x 192 194 * 193 * @param string $name194 * @param string $defaultValue195 * @return string 195 * @param string $name 196 * @param string $defaultValue 197 * @return string|null 196 198 */ 197 199 public function getParam($name, $defaultValue = null) 198 200 { 199 $result = '';200 201 if ( isset($this->url['query']) === false) {202 return $defaultValue;201 $result = $defaultValue; 202 203 if ($this->hasQuery() === false) { 204 $queryValues = null; 203 205 } else { 204 206 $queryValues = explode('?', $this->url['query']); … … 207 209 switch($name) { 208 210 case 'attributes': 209 $result = $queryValues[0]; 211 $result = ($queryValues !== null 212 && $queryValues[0] !== '') ? $queryValues[0] : ''; 210 213 break; 211 214 212 215 case 'scope': 213 $result = (count($queryValues) >= 2) ? $queryValues[1] : null; 216 $result = ($queryValues !== null 217 && count($queryValues) >= 2 218 && $queryValues[1] !== '') ? $queryValues[1] : 'base'; 214 219 break; 215 220 216 221 case 'filter': 217 $result = (count($queryValues) >= 3) ? $queryValues[2] : null; 222 $result = ($queryValues !== null 223 && count($queryValues) >= 3 224 && $queryValues[2] !== '') ? $queryValues[2] : 'objectClass=*'; 218 225 break; 219 226 220 227 default: 221 return $defaultValue;228 // intentionally empty 222 229 } 223 230 … … 275 282 276 283 /** 277 * Returns a stubLDAPConnection 284 * Returns a stubLDAPConnection. 278 285 * 279 286 * @return stubLDAPConnection
