@@ -474,19 +474,18 @@ public function username2dn($name) {
474474 * returns the internal ownCloud name for the given LDAP DN of the group, false on DN outside of search DN or failure
475475 *
476476 * @param string $fdn the dn of the group object
477- * @param string $ldapName optional, the display name of the object
478477 * @return string|false with the name to use in ownCloud, false on DN outside of search DN
479478 * @throws \OC\ServerNotAvailableException
480479 */
481- public function dn2groupname ($ fdn, $ ldapName = null ) {
480+ public function dn2groupname ($ fdn ) {
482481 //To avoid bypassing the base DN settings under certain circumstances
483482 //with the group support, check whether the provided DN matches one of
484483 //the given Bases
485484 if (!$ this ->isDNPartOfBase ($ fdn , $ this ->connection ->ldapBaseGroups )) {
486485 return false ;
487486 }
488487
489- return $ this ->dn2ocname ($ fdn , $ ldapName , false );
488+ return $ this ->dn2ocname ($ fdn , false );
490489 }
491490
492491 /**
@@ -532,38 +531,36 @@ public function groupsMatchFilter($groupDNs) {
532531 * returns the internal ownCloud name for the given LDAP DN of the user, false on DN outside of search DN or failure
533532 *
534533 * @param string $fdn the dn of the user object
535- * @param string $ldapName optional, the display name of the object
536534 * @return string|false with with the name to use in ownCloud
537535 * @throws \OC\ServerNotAvailableException
538536 */
539- public function dn2username ($ fdn, $ ldapName = null ) {
537+ public function dn2username ($ fdn ) {
540538 //To avoid bypassing the base DN settings under certain circumstances
541539 //with the group support, check whether the provided DN matches one of
542540 //the given Bases
543541 if (!$ this ->isDNPartOfBase ($ fdn , $ this ->connection ->ldapBaseUsers )) {
544542 return false ;
545543 }
546544
547- return $ this ->dn2ocname ($ fdn , $ ldapName , true );
545+ return $ this ->dn2ocname ($ fdn , true );
548546 }
549547
550548 /**
551549 * returns an internal ownCloud name for the given LDAP DN, false on DN outside of search DN
552550 *
553551 * @param string $fdn the dn of the user object
554- * @param string $ldapDisplayName optional, the display name of the object
555552 * @param bool $isUser optional, whether it is a user object (otherwise group assumed)
556553 * @return string|false with with the name to use in ownCloud
557554 * @throws \BadMethodCallException
558555 * @throws \OC\ServerNotAvailableException
559556 */
560- public function dn2ocname ($ fdn , $ ldapDisplayName = null , $ isUser = true ) {
557+ public function dn2ocname ($ fdn , $ isUser = true ) {
561558 if ($ isUser ) {
562559 $ mapper = $ this ->getUserMapper ();
563- $ displayNameAttribute = $ this ->connection ->ldapUserDisplayName ;
560+ $ nameAttribute = ( string ) $ this ->connection ->ldapExpertUsernameAttr ;
564561 } else {
565562 $ mapper = $ this ->getGroupMapper ();
566- $ displayNameAttribute = $ this ->connection ->ldapGroupDisplayName ;
563+ $ nameAttribute = ( string ) $ this ->connection ->ldapExpertGroupnameAttr ;
567564 }
568565
569566 //let's try to retrieve the ownCloud name from the mappings table
@@ -589,29 +586,16 @@ public function dn2ocname($fdn, $ldapDisplayName = null, $isUser = true) {
589586 return false ;
590587 }
591588
592- if ($ ldapDisplayName === null ) {
593- $ ldapDisplayName = $ this ->readAttribute ($ fdn , $ displayNameAttribute );
594- if (!isset ($ ldapDisplayName [0 ]) && empty ($ ldapDisplayName [0 ])) {
595- \OC ::$ server ->getLogger ()->error (
596- "No or empty name for $ fdn. " ,
597- ['app ' => 'user_ldap ' ]
598- );
599- return false ;
600- }
601- $ ldapDisplayName = $ ldapDisplayName [0 ];
589+ if ($ nameAttribute !== '' ) {
590+ $ name = $ this ->readAttribute ($ fdn , $ nameAttribute );
591+ $ name = $ name [0 ];
592+ } else {
593+ $ name = $ uuid ;
602594 }
603595
596+ $ intName = $ name ;
604597 if ($ isUser ) {
605- $ usernameAttribute = (string )$ this ->connection ->ldapExpertUsernameAttr ;
606- if ($ usernameAttribute !== '' ) {
607- $ username = $ this ->readAttribute ($ fdn , $ usernameAttribute );
608- $ username = $ username [0 ];
609- } else {
610- $ username = $ uuid ;
611- }
612- $ intName = $ this ->sanitizeUsername ($ username );
613- } else {
614- $ intName = $ ldapDisplayName ;
598+ $ intName = $ this ->sanitizeUsername ($ name );
615599 }
616600
617601 //a new user/group! Add it only if it doesn't conflict with other backend's users or existing groups
@@ -709,22 +693,10 @@ public function ownCloudGroupNames($ldapGroups) {
709693 * @throws \OC\ServerNotAvailableException
710694 */
711695 private function ldap2ownCloudNames ($ ldapObjects , $ isUsers ) {
712- if ($ isUsers ) {
713- $ nameAttribute = $ this ->connection ->ldapUserDisplayName ;
714- $ sndAttribute = $ this ->connection ->ldapUserDisplayName2 ;
715- } else {
716- $ nameAttribute = $ this ->connection ->ldapGroupDisplayName ;
717- }
718696 $ ownCloudNames = [];
719697
720698 foreach ($ ldapObjects as $ ldapObject ) {
721- $ nameByLDAP = null ;
722- if (isset ($ ldapObject [$ nameAttribute ][0 ])) {
723- // might be set, but not necessarily. if so, we use it.
724- $ nameByLDAP = $ ldapObject [$ nameAttribute ][0 ];
725- }
726-
727- $ ocName = $ this ->dn2ocname ($ ldapObject ['dn ' ][0 ], $ nameByLDAP , $ isUsers );
699+ $ ocName = $ this ->dn2ocname ($ ldapObject ['dn ' ][0 ], $ isUsers );
728700 if ($ ocName ) {
729701 $ ownCloudNames [$ ldapObject ['dn ' ][0 ]] = $ ocName ;
730702 }
0 commit comments