Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc: How to search for users in multiple LDAP groups #1080

Merged
merged 5 commits into from
Dec 13, 2021

Conversation

jifox
Copy link
Contributor

@jifox jifox commented Nov 16, 2021

Extend https://nautobot.readthedocs.io/en/latest/configuration/authentication/ldap/#user-authentication documentation to show how to search multiple LDAP Groups for users.

Added text:

The following snippet shows how to search for users in multiple LDAP groups:

  • Define the user-groups in *.env file (delimiter ';')

    # Groups to search for user objects. "(sAMAccountName=%(user)s),..."
    NAUTOBOT_AUTH_LDAP_USER_SEARCH_DN=OU=IT-Admins,OU=special-users,OU=Acme-User,DC=Acme,DC=local;OU=Infrastruktur,OU=IT,OU=my-location,OU=User,OU=Acme-User,DC=Acme,DC=local
  • Import LDAPSearchUnion in nautobot_config.py

    from django_auth_ldap.config import ..., LDAPSearchUnion
  • In nautobot_config.py replace the AUTH_LDAP_USER_SEARCH command from above with:

    user_search_dn_list = str(AUTH_LDAP_USER_SEARCH_DN).split(";")
    ldapsearch_objects = []
    for sdn in user_search_dn_list:
        ldapsearch_objects.append(LDAPSearch(sdn.strip(), ldap.SCOPE_SUBTREE, "(sAMAccountName=%(user)s)"))
    AUTH_LDAP_USER_SEARCH = LDAPSearchUnion(*ldapsearch_objects)

Copy link
Contributor

@glennmatthews glennmatthews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

nautobot/docs/configuration/authentication/ldap.md Outdated Show resolved Hide resolved
nautobot/docs/configuration/authentication/ldap.md Outdated Show resolved Hide resolved
jifox and others added 2 commits December 8, 2021 16:47
Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com>
@jifox
Copy link
Contributor Author

jifox commented Dec 8, 2021

I've fixed the render problem and added os.getenv(... to example code.

Copy link
Contributor

@glennmatthews glennmatthews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@glennmatthews glennmatthews merged commit 7d1a262 into nautobot:develop Dec 13, 2021
glennmatthews added a commit that referenced this pull request Dec 13, 2021
@jifox jifox deleted the jifox-ldap-documentation branch December 14, 2021 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants