How change jovyan user by userid from annuaire LDAP in jupyterLab

Hi,

I have a docker compose that contain 3 services: jupyterhub, jupyterlab and traefic.
When I connect on jupyterlab console I have the user by default jovyan, I would like to change it by the userid. I tried many solutions (configurations I mean), I searched a forums, I tried to do the same according my use, but still I have jovyan user in jupyterlab console.

I did an ldapsearch request to display all groups LDAP of users, it works well:

ldapsearch -x -D "cn=proxyagent"  -H ldaps://annuaire_ldap -b 'ou=1111,o=2222'   '(&(cn=333*)(memberuid=my_login))' -w password

I tried to add these configuratins in jupyterhub_config.py, but still in vein.
I tried also to add the real parameters in c.Spawner.environment, when I add the real values I got my login as user connected in jupyterlab instead of jovyan, but I don’t know hpw can I generalize it the command line bellow.

c.Spawner.environment = {'GRANT_SUDO': 'yes', "NB_USER": "{login}", "NB_UID" :"89211","NB_GID" : 79999}

My configurations in jupyterhub_config.py is the following:

c.JupyterHub.authenticator_class = 'ldapauthenticator.LDAPAuthenticator'
# Must match LDAPAuthenticatorInfoUID.pre_spawn_start
c.LDAPAuthenticator.server_address = 'ldaps://server_name:port'
c.LDAPAuthenticator.server_port = port_number
# obligatoire pour trouver l'user dans l'annuaire LDAP

c.LDAPAuthenticator.lookup_dn = True
c.LDAPAuthenticator.lookup_dn_search_filter = '({login_attr}={login})'
c.LDAPAuthenticator.lookup_dn_search_user = 'cn=proxyagent'
c.LDAPAuthenticator.lookup_dn_search_password = 'password'
c.LDAPAuthenticator.user_search_base = "ou=Nominatifs,ou=company,ou=People,o=oudcompany"
c.LDAPAuthenticator.user_attribute = 'uid'
c.LDAPAuthenticator.lookup_dn_user_dn_attribute = 'cn'
c.LDAPAuthenticator.escape_userdn = False
#c.LDAPAuthenticator.search_filter = '(&(cn=gdx*)(memberuid={username}))'
c.LDAPAuthenticator.auth_state_attributes = ['uid', 'uidNumber']
c.LDAPAuthenticator.use_lookup_dn_username=False

Really I need your help and expertise. How can I modify the configuration to return the userid in jupyterlab console instead of jovyan ?
Links that I tried there solutions:
https://github.com/hansohn/jupyterhub-ldap-authenticator

And:

jupyterhub-ldap-authenticator

Please help, Thanks a lot

Have a look at

It’s out of date (the referenced PR was merged and released so the configuration is now a lot simpler) but the general principles should help you.

Thanks for your answer. I followed this configuration.
I added user_info_attributes it changed user_attributes its returned value is unicode, I cannot give it 2 values like in the example.
I added also auth_state, it also changes to auth_state_attributes.

My configuration in jupyter_config.py is the following:

c.JupyterHub.authenticator_class = 'ldapauthenticator.LDAPAuthenticator'
c.LDAPAuthenticator.server_address = 'ldaps://server:port'
c.LDAPAuthenticator.server_port = port
c.LDAPAuthenticator.lookup_dn = True
c.LDAPAuthenticator.lookup_dn_search_filter = '({login_attr}={login})'
c.LDAPAuthenticator.lookup_dn_search_user = 'cn=proxyagent'
c.LDAPAuthenticator.lookup_dn_search_password = 'password'
c.LDAPAuthenticator.bind_user_dn = "uid={username},ou=Nominatifs,ou=company,ou=People,o=company"
c.LDAPAuthenticator.user_search_base = "ou=Nominatifs,ou=company,ou=People,o=company"
c.LDAPAuthenticator.user_attribute = "uid"
c.LDAPAuthenticator.lookup_dn_user_dn_attribute = 'cn'
c.LDAPAuthenticator.escape_userdn = False
c.LDAPAuthenticator.auth_state_attributes = ["uidNumber","gidNumber","uid"]
c.LDAPAuthenticator.create_user_home_dir = True
c.LDAPAuthenticator.create_user_home_dir_cmd = ['mkhomedir_helper']
c.LDAPAuthenticator.use_lookup_dn_username=True

This file zero-to-jupyterhub-config.yml is it required ? if yes, where can I put it and call it ?
In the example that you sent it, it’s mentionned:
Either build a custom JupyterHub Docker image with these changes, or define a new class in-line in the Hub configuration as done here ==> Sorry I didn’t understand which modification I should add it in the image ?

Thanks a lot for your answer and understanding in advance