Data location path based on substr of user name (CN)

Hi All,

Update: I solved this by manually punching in the values to the oc_external_applicable, oc_external_config, oc_external_mounts, and oc_external_options tables via a Python script running from a cron job.

I’ll apologize in advance for this question, it’s probably a very niche problem.

I have 5000+ user accounts that authenticate to a NextCloud 12 Linux instance via Windows AD / LDAP. I have the users AD home folders root share mounted on the the Linux server (cifs) and need to set the NextCloud user external storage path per user. I’ve used “$user” before with external storage but the cifs mount contained the CN-based folder names directly under it (e.g., /mnt/share/username). The problem here is that the AD home folder paths are an A-Z structure based on the first letter of the users’ CN and look something like \server\share[A-Z]\username – for example: \server\share\u\username.

I guess what I need is some sort of substring-macro-ish thing, something like $substr($user,0,1), to modify the external storage path per user. I’m reasonably proficient in PHP, Perl, and Python so I’m not above having to hack something together to make this work. I was just hoping for some sort of divine intervention from you guys telling me I’m missing something and this is super easy to do, or at the very least, some direction on where I would start.