Code Duplication    Length = 7-8 lines in 2 locations

apps/user_ldap/lib/User_LDAP.php 1 location

@@ 193-199 (lines=7) @@
190
		$dn = $ldapRecord['dn'][0];
191
		$user = $this->access->userManager->get($dn);
192
193
		if(!$user instanceof User) {
194
			Util::writeLog('user_ldap',
195
				'LDAP Login: Could not get user object for DN ' . $dn .
196
				'. Maybe the LDAP entry has no set display name attribute?',
197
				ILogger::WARN);
198
			return false;
199
		}
200
		if($user->getUsername() !== false) {
201
			//are the credentials OK?
202
			if(!$this->access->areCredentialsValid($dn, $password)) {

apps/user_ldap/lib/Access.php 1 location

@@ 271-278 (lines=8) @@
268
		$this->initPagedSearch($filter, array($dn), array($attribute), $maxResults, 0);
269
		$dn = $this->helper->DNasBaseParameter($dn);
270
		$rr = @$this->invokeLDAPMethod('read', $cr, $dn, $filter, array($attribute));
271
		if (!$this->ldap->isResource($rr)) {
272
			if ($attribute !== '') {
273
				//do not throw this message on userExists check, irritates
274
				\OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN ' . $dn, ILogger::DEBUG);
275
			}
276
			//in case an error occurs , e.g. object does not exist
277
			return false;
278
		}
279
		if ($attribute === '' && ($filter === 'objectclass=*' || $this->invokeLDAPMethod('countEntries', $cr, $rr) === 1)) {
280
			\OCP\Util::writeLog('user_ldap', 'readAttribute: ' . $dn . ' found', ILogger::DEBUG);
281
			return true;