@@ -449,18 +449,19 @@ public function username2dn($name) {
449449 *
450450 * @param string $fdn the dn of the group object
451451 * @param string $ldapName optional, the display name of the object
452+ * @param bool $autoMapping Should the group be mapped if not yet mapped
452453 * @return string|false with the name to use in Nextcloud, false on DN outside of search DN
453454 * @throws \Exception
454455 */
455- public function dn2groupname ($ fdn , $ ldapName = null ) {
456+ public function dn2groupname ($ fdn , $ ldapName = null , bool $ autoMapping = true ) {
456457 //To avoid bypassing the base DN settings under certain circumstances
457458 //with the group support, check whether the provided DN matches one of
458459 //the given Bases
459460 if (!$ this ->isDNPartOfBase ($ fdn , $ this ->connection ->ldapBaseGroups )) {
460461 return false ;
461462 }
462463
463- return $ this ->dn2ocname ($ fdn , $ ldapName , false );
464+ return $ this ->dn2ocname ($ fdn , $ ldapName , false , autoMapping: $ autoMapping );
464465 }
465466
466467 /**
@@ -490,10 +491,11 @@ public function dn2username($fdn, $ldapName = null) {
490491 * @param bool $isUser optional, whether it is a user object (otherwise group assumed)
491492 * @param bool|null $newlyMapped
492493 * @param array|null $record
494+ * @param bool $autoMapping Should the group be mapped if not yet mapped
493495 * @return false|string with with the name to use in Nextcloud
494496 * @throws \Exception
495497 */
496- public function dn2ocname ($ fdn , $ ldapName = null , $ isUser = true , &$ newlyMapped = null , ?array $ record = null ) {
498+ public function dn2ocname ($ fdn , $ ldapName = null , $ isUser = true , &$ newlyMapped = null , ?array $ record = null , bool $ autoMapping = true ) {
497499 static $ intermediates = [];
498500 if (isset ($ intermediates [($ isUser ? 'user- ' : 'group- ' ) . $ fdn ])) {
499501 return false ; // is a known intermediate
@@ -516,6 +518,11 @@ public function dn2ocname($fdn, $ldapName = null, $isUser = true, &$newlyMapped
516518 return $ ncName ;
517519 }
518520
521+ if (!$ autoMapping ) {
522+ /* If no auto mapping, stop there */
523+ return false ;
524+ }
525+
519526 //second try: get the UUID and check if it is known. Then, update the DN and return the name.
520527 $ uuid = $ this ->getUUID ($ fdn , $ isUser , $ record );
521528 if (is_string ($ uuid )) {
0 commit comments