Creatin LDAP users by logon name, not UID

Hi,
I use nextcloud with Active Directory grıup membership.
When I add user into AD grıup user created in Nextcloud side but not wiht logon name or SAMAccountname. It creates by Object GUID.
For example my username is tevfikceydelikler and my object GUID is 99 8F E9 2B 69 89 EA 4C 9F 71 FC 6C B5 97 07 95
When I add myself to NexctCloud AD group, My username is becomes: 2BE98F99-8969-4CEA-9F71-FC6CB5970795

And OS sees like:
/data/2BE98F99-8969-4CEA-9F71-FC6CB5970795

IS there any way to create user by SAMAccountname?
I mean:
/data/tevfikceydeliler
Regards,

Yes this is possible. Sorry I do not have the answer ready straight out of my mind. However I am pretty sure it is possible. If my memory do not fails me, look at the matching policy (attribute for uniqueness). I am pretty sure NC creates users folders with their unique userid.

There is a little bit, tiny question remains.
How?
:slight_smile:

LDAP/AD Integration under settings:

Advanced->Special attributes->Naming rule for the users folder

My interface is in danish, so this is freely translated.

However this will work for only any user created AFTER the change of that setting.

Hi,
I think It solves my problem
After change special attiributes like this and add user to my usergroup, user folder creating by username., not UUID

Thanks

1 Like

It not solves my problem unfortunately.
I just want to see username instead of UUID in /data directory why add ldap user

It will not automatically change the folder names of each user for any existing users after that modification. In fact you can verify that Nextcloud calculates the user paths to data/sAMAccountName by adding the users data path to your users admin overview (the gear in the bottom left, checkmark for userpaths). Then what you needs to do (unfortunately but easy to work with) is to rename each users folder.

Example. Lets assume we have John Doe with the sAMAccountName=jodo and the UUID=6bf36926-0f6c-103b-95c0-0f67437e8985:

mkdir /var/www/nextcloud/data/jodo/
chown www-data /var/www/nextcloud/data/jodo/
mv /var/www/nextcloud/data/6bf36926-0f6c-103b-95c0-0f67437e8985/* /var/www/nextcloud/data/jodo/

This is only needed for each user not yet logged in first time to Nextcloud (which also covers new users). When the existing user folders has been renamed, run:

sudo -u www-data php8.1 /var/www/nextcloud/occ maintenance:repair
sudo -u www-data php8.1 /var/www/nextcloud/occ files:repair-tree
sudo -u www-data php8.1 /var/www/nextcloud/occ files:scan --all

I just tested this and done it in my production environment, with no issues.

1 Like

Understand.
So NC cant do it automatically this mapping.
Thnx for your assistances.

Did you read what I wrote? Yes NC can do that mapping. But for obvious reason it does not pull the plug of users cache, indices, previews and other stuff “automatically”, which is why setting this option does not - automatically - change it for existing users (as in existing nextcloud users). ANY new nextcloud user will be created using the new naming standard. So for this to also affect existing users, you has to follow a manuel approach, which also includes re-building indices, cache, previews and so on, for each existing nextcloud user folders only.

1 Like

Understand, Bu maybe my bad, It is fresh installed and not in production yes.
Let me test it today.
Test:

  1. Change LDAP advanced settings (User Home Folder Naming Rule) s > add amaccount name
  2. Add user to AD group
  3. Check this user and other user login successfull or not
  4. Upload file
    .5. Sharing file
    etc.
    regards,
1 Like

And the user might not be “created” in the nextcloud database and on the filepath before they logs in the first time.

Is it possible to do with a command ? I can add to crontab if it is exist.

Have you tested this? Does it create the folder with desired name?

I can confirm that it works in my end.

Exactly.
It works.
Really thanks you for your assistances.

1 Like