Skip to content

Commit 8930ef2

Browse files
committed
Add setting to force LDAP UUID case
* Fix #44486 Signed-off-by: Sven Seeberg <mail@sven-seeberg.de>
1 parent 4b7b9c3 commit 8930ef2

File tree

7 files changed

+23
-3
lines changed

7 files changed

+23
-3
lines changed

apps/user_ldap/js/wizard/wizardTabExpert.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ OCA = OCA || {};
3636
$element: $('#ldap_expert_uuid_group_attr'),
3737
setMethod: 'setGroupUUIDAttribute'
3838
},
39+
ldap_expert_force_uuid_case: {
40+
$element: $('#ldap_expert_force_uuid_case'),
41+
setMethod: 'setGroupUUIDAttribute'
42+
},
3943

4044
//Buttons
4145
ldap_action_clear_user_mappings: {

apps/user_ldap/lib/Access.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,11 @@ public function getUUID(string $dn, bool $isUser = true, array $ldapRecord = nul
17541754
$uuid = $uuid[0];
17551755
}
17561756
}
1757-
1757+
if ( $this->connection->ldapExpertForceUUIDCase === "lowercase" ) {
1758+
$uuid = strtolower($uuid);
1759+
} elseif ( $this->connection->ldapExpertForceUUIDCase === "uppercase" ) {
1760+
$uuid = strtoupper($uuid);
1761+
}
17581762
return $uuid;
17591763
}
17601764

apps/user_ldap/lib/Configuration.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class Configuration {
115115
'hasMemberOfFilterSupport' => false,
116116
'useMemberOfToDetectMembership' => true,
117117
'ldapExpertUsernameAttr' => null,
118+
'ldapExpertForceUUIDCase' => 'accept',
118119
'ldapExpertUUIDUserAttr' => null,
119120
'ldapExpertUUIDGroupAttr' => null,
120121
'markRemnantsAsDisabled' => false,
@@ -470,6 +471,7 @@ public function getDefaults(): array {
470471
'ldap_expert_username_attr' => '',
471472
'ldap_expert_uuid_user_attr' => '',
472473
'ldap_expert_uuid_group_attr' => '',
474+
'ldap_expert_force_uuid_case' => 'accept',
473475
'has_memberof_filter_support' => 0,
474476
'use_memberof_to_detect_membership' => 1,
475477
'ldap_mark_remnants_as_disabled' => 0,
@@ -546,6 +548,7 @@ public function getConfigTranslationArray(): array {
546548
'ldap_attributes_for_group_search' => 'ldapAttributesForGroupSearch',
547549
'ldap_expert_username_attr' => 'ldapExpertUsernameAttr',
548550
'ldap_expert_uuid_user_attr' => 'ldapExpertUUIDUserAttr',
551+
'ldap_expert_force_uuid_case' => 'ldapExpertForceUUIDCase',
549552
'ldap_expert_uuid_group_attr' => 'ldapExpertUUIDGroupAttr',
550553
'has_memberof_filter_support' => 'hasMemberOfFilterSupport',
551554
'use_memberof_to_detect_membership' => 'useMemberOfToDetectMembership',

apps/user_ldap/lib/Connection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
* @property bool|mixed|void ldapGroupMemberAssocAttr
5757
* @property string ldapUuidUserAttribute
5858
* @property string ldapUuidGroupAttribute
59+
* @property string ldapExpertForceUUIDCase
5960
* @property string ldapExpertUUIDUserAttr
6061
* @property string ldapExpertUUIDGroupAttr
6162
* @property string ldapQuotaAttribute

apps/user_ldap/lib/Controller/ConfigAPIController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ public function modify($configID, $configData) {
210210
* <ldapExpertUsernameAttr>uid</ldapExpertUsernameAttr>
211211
* <ldapExpertUUIDUserAttr>uid</ldapExpertUUIDUserAttr>
212212
* <ldapExpertUUIDGroupAttr></ldapExpertUUIDGroupAttr>
213+
* <ldapExpertForceUUIDCase>accept</ldapExpertForceUUIDCase>
213214
* <lastJpegPhotoLookup>0</lastJpegPhotoLookup>
214215
* <ldapNestedGroups>0</ldapNestedGroups>
215216
* <ldapPagingSize>500</ldapPagingSize>

apps/user_ldap/openapi.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
"get": {
122122
"operationId": "configapi-show",
123123
"summary": "Get a configuration",
124-
"description": "Output can look like this: <?xml version=\"1.0\"?> <ocs> <meta> <status>ok</status> <statuscode>200</statuscode> <message>OK</message> </meta> <data> <ldapHost>ldaps://my.ldap.server</ldapHost> <ldapPort>7770</ldapPort> <ldapBackupHost></ldapBackupHost> <ldapBackupPort></ldapBackupPort> <ldapBase>ou=small,dc=my,dc=ldap,dc=server</ldapBase> <ldapBaseUsers>ou=users,ou=small,dc=my,dc=ldap,dc=server</ldapBaseUsers> <ldapBaseGroups>ou=small,dc=my,dc=ldap,dc=server</ldapBaseGroups> <ldapAgentName>cn=root,dc=my,dc=ldap,dc=server</ldapAgentName> <ldapAgentPassword>clearTextWithShowPassword=1</ldapAgentPassword> <ldapTLS>1</ldapTLS> <turnOffCertCheck>0</turnOffCertCheck> <ldapIgnoreNamingRules/> <ldapUserDisplayName>displayname</ldapUserDisplayName> <ldapUserDisplayName2>uid</ldapUserDisplayName2> <ldapUserFilterObjectclass>inetOrgPerson</ldapUserFilterObjectclass> <ldapUserFilterGroups></ldapUserFilterGroups> <ldapUserFilter>(&amp;(objectclass=nextcloudUser)(nextcloudEnabled=TRUE))</ldapUserFilter> <ldapUserFilterMode>1</ldapUserFilterMode> <ldapGroupFilter>(&amp;(|(objectclass=nextcloudGroup)))</ldapGroupFilter> <ldapGroupFilterMode>0</ldapGroupFilterMode> <ldapGroupFilterObjectclass>nextcloudGroup</ldapGroupFilterObjectclass> <ldapGroupFilterGroups></ldapGroupFilterGroups> <ldapGroupDisplayName>cn</ldapGroupDisplayName> <ldapGroupMemberAssocAttr>memberUid</ldapGroupMemberAssocAttr> <ldapLoginFilter>(&amp;(|(objectclass=inetOrgPerson))(uid=%uid))</ldapLoginFilter> <ldapLoginFilterMode>0</ldapLoginFilterMode> <ldapLoginFilterEmail>0</ldapLoginFilterEmail> <ldapLoginFilterUsername>1</ldapLoginFilterUsername> <ldapLoginFilterAttributes></ldapLoginFilterAttributes> <ldapQuotaAttribute></ldapQuotaAttribute> <ldapQuotaDefault></ldapQuotaDefault> <ldapEmailAttribute>mail</ldapEmailAttribute> <ldapCacheTTL>20</ldapCacheTTL> <ldapUuidUserAttribute>auto</ldapUuidUserAttribute> <ldapUuidGroupAttribute>auto</ldapUuidGroupAttribute> <ldapOverrideMainServer></ldapOverrideMainServer> <ldapConfigurationActive>1</ldapConfigurationActive> <ldapAttributesForUserSearch>uid;sn;givenname</ldapAttributesForUserSearch> <ldapAttributesForGroupSearch></ldapAttributesForGroupSearch> <ldapExperiencedAdmin>0</ldapExperiencedAdmin> <homeFolderNamingRule></homeFolderNamingRule> <hasMemberOfFilterSupport></hasMemberOfFilterSupport> <useMemberOfToDetectMembership>1</useMemberOfToDetectMembership> <ldapExpertUsernameAttr>uid</ldapExpertUsernameAttr> <ldapExpertUUIDUserAttr>uid</ldapExpertUUIDUserAttr> <ldapExpertUUIDGroupAttr></ldapExpertUUIDGroupAttr> <lastJpegPhotoLookup>0</lastJpegPhotoLookup> <ldapNestedGroups>0</ldapNestedGroups> <ldapPagingSize>500</ldapPagingSize> <turnOnPasswordChange>1</turnOnPasswordChange> <ldapDynamicGroupMemberURL></ldapDynamicGroupMemberURL> </data> </ocs>\nThis endpoint requires admin access",
124+
"description": "Output can look like this: <?xml version=\"1.0\"?> <ocs> <meta> <status>ok</status> <statuscode>200</statuscode> <message>OK</message> </meta> <data> <ldapHost>ldaps://my.ldap.server</ldapHost> <ldapPort>7770</ldapPort> <ldapBackupHost></ldapBackupHost> <ldapBackupPort></ldapBackupPort> <ldapBase>ou=small,dc=my,dc=ldap,dc=server</ldapBase> <ldapBaseUsers>ou=users,ou=small,dc=my,dc=ldap,dc=server</ldapBaseUsers> <ldapBaseGroups>ou=small,dc=my,dc=ldap,dc=server</ldapBaseGroups> <ldapAgentName>cn=root,dc=my,dc=ldap,dc=server</ldapAgentName> <ldapAgentPassword>clearTextWithShowPassword=1</ldapAgentPassword> <ldapTLS>1</ldapTLS> <turnOffCertCheck>0</turnOffCertCheck> <ldapIgnoreNamingRules/> <ldapUserDisplayName>displayname</ldapUserDisplayName> <ldapUserDisplayName2>uid</ldapUserDisplayName2> <ldapUserFilterObjectclass>inetOrgPerson</ldapUserFilterObjectclass> <ldapUserFilterGroups></ldapUserFilterGroups> <ldapUserFilter>(&amp;(objectclass=nextcloudUser)(nextcloudEnabled=TRUE))</ldapUserFilter> <ldapUserFilterMode>1</ldapUserFilterMode> <ldapGroupFilter>(&amp;(|(objectclass=nextcloudGroup)))</ldapGroupFilter> <ldapGroupFilterMode>0</ldapGroupFilterMode> <ldapGroupFilterObjectclass>nextcloudGroup</ldapGroupFilterObjectclass> <ldapGroupFilterGroups></ldapGroupFilterGroups> <ldapGroupDisplayName>cn</ldapGroupDisplayName> <ldapGroupMemberAssocAttr>memberUid</ldapGroupMemberAssocAttr> <ldapLoginFilter>(&amp;(|(objectclass=inetOrgPerson))(uid=%uid))</ldapLoginFilter> <ldapLoginFilterMode>0</ldapLoginFilterMode> <ldapLoginFilterEmail>0</ldapLoginFilterEmail> <ldapLoginFilterUsername>1</ldapLoginFilterUsername> <ldapLoginFilterAttributes></ldapLoginFilterAttributes> <ldapQuotaAttribute></ldapQuotaAttribute> <ldapQuotaDefault></ldapQuotaDefault> <ldapEmailAttribute>mail</ldapEmailAttribute> <ldapCacheTTL>20</ldapCacheTTL> <ldapUuidUserAttribute>auto</ldapUuidUserAttribute> <ldapUuidGroupAttribute>auto</ldapUuidGroupAttribute> <ldapOverrideMainServer></ldapOverrideMainServer> <ldapConfigurationActive>1</ldapConfigurationActive> <ldapAttributesForUserSearch>uid;sn;givenname</ldapAttributesForUserSearch> <ldapAttributesForGroupSearch></ldapAttributesForGroupSearch> <ldapExperiencedAdmin>0</ldapExperiencedAdmin> <homeFolderNamingRule></homeFolderNamingRule> <hasMemberOfFilterSupport></hasMemberOfFilterSupport> <useMemberOfToDetectMembership>1</useMemberOfToDetectMembership> <ldapExpertUsernameAttr>uid</ldapExpertUsernameAttr> <ldapExpertForceUUIDCase>accept</ldapExpertForceUUIDCase> <ldapExpertUUIDUserAttr>uid</ldapExpertUUIDUserAttr> <ldapExpertUUIDGroupAttr></ldapExpertUUIDGroupAttr> <lastJpegPhotoLookup>0</lastJpegPhotoLookup> <ldapNestedGroups>0</ldapNestedGroups> <ldapPagingSize>500</ldapPagingSize> <turnOnPasswordChange>1</turnOnPasswordChange> <ldapDynamicGroupMemberURL></ldapDynamicGroupMemberURL> </data> </ocs>\nThis endpoint requires admin access",
125125
"tags": [
126126
"configapi"
127127
],
@@ -389,4 +389,4 @@
389389
}
390390
},
391391
"tags": []
392-
}
392+
}

apps/user_ldap/templates/settings.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@
140140
<p><strong><?php p($l->t('Internal Username'));?></strong></p>
141141
<p class="ldapIndent"><?php p($l->t('By default the internal username will be created from the UUID attribute. It makes sure that the username is unique and characters do not need to be converted. The internal username has the restriction that only these characters are allowed: [a-zA-Z0-9_.@-]. Other characters are replaced with their ASCII correspondence or simply omitted. On collisions a number will be added/increased. The internal username is used to identify a user internally. It is also the default name for the user home folder. It is also a part of remote URLs, for instance for all DAV services. With this setting, the default behavior can be overridden. Changes will have effect only on newly mapped (added) LDAP users. Leave it empty for default behavior.'));?></p>
142142
<p class="ldapIndent"><label for="ldap_expert_username_attr"><?php p($l->t('Internal Username Attribute:'));?></label><input type="text" id="ldap_expert_username_attr" name="ldap_expert_username_attr" data-default="<?php p($_['ldap_expert_username_attr_default']); ?>" /></p>
143+
<p class="ldapIndent"><label for="ldap_expert_force_uuid_case"><?php p($l->t('Force Case for UUIDs:'));?></label><select id="ldap_expert_force_uuid_case" name="ldap_expert_force_uuid_case" data-default="<?php p($_['ldap_expert_force_uuid_case_default']); ?>" ><option value="accept"<?php if (isset($_['ldap_expert_force_uuid_case']) && ($_['ldap_expert_force_uuid_case'] === 'accept')) {
144+
p(' selected');
145+
} ?>><?php p($l->t('Accept case from LDAP'));?></option><option value="lowercase"<?php if (isset($_['ldap_expert_force_uuid_case']) && ($_['ldap_expert_force_uuid_case'] === 'lowercase')) {
146+
p(' selected');
147+
} ?>><?php p($l->t('Convert UUID to Lower Case Username'));?></option><option value="uppercase"<?php if (isset($_['ldap_expert_force_uuid_case']) && ($_['ldap_expert_force_uuid_case'] === 'uppercase')) {
148+
p(' selected');
149+
} ?>><?php p($l->t('Convert UUID to Upper Case Username'));?></option></select>
143150
<p><strong><?php p($l->t('Override UUID detection'));?></strong></p>
144151
<p class="ldapIndent"><?php p($l->t('By default, the UUID attribute is automatically detected. The UUID attribute is used to doubtlessly identify LDAP users and groups. Also, the internal username will be created based on the UUID, if not specified otherwise above. You can override the setting and pass an attribute of your choice. You must make sure that the attribute of your choice can be fetched for both users and groups and it is unique. Leave it empty for default behavior. Changes will have effect only on newly mapped (added) LDAP users and groups.'));?></p>
145152
<p class="ldapIndent"><label for="ldap_expert_uuid_user_attr"><?php p($l->t('UUID Attribute for Users:'));?></label><input type="text" id="ldap_expert_uuid_user_attr" name="ldap_expert_uuid_user_attr" data-default="<?php p($_['ldap_expert_uuid_user_attr_default']); ?>" /></p>

0 commit comments

Comments
 (0)