# Question on Configuring multiple ldap user search using awx.awx.tower\_settings

**URL:** <https://forum.ansible.com/t/question-on-configuring-multiple-ldap-user-search-using-awx-awx-tower-settings/36655>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [May 24, 2022, 11:43am UTC](https://forum.ansible.com/t/question-on-configuring-multiple-ldap-user-search-using-awx-awx-tower-settings/36655 "2022-05-24T11:43:12Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![rake](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@rake](https://forum.ansible.com/u/rake)\
**Post date:** [May 24, 2022, 11:43am UTC](https://forum.ansible.com/t/question-on-configuring-multiple-ldap-user-search-using-awx-awx-tower-settings/36655/1 "2022-05-24T11:43:12Z")

</div>

Hello Team,

I have ansible playbook that uses module awx.awx.tower\_settings to do AUTH\_LDAP\_USER\_SEARCH.I’m trying to configure two ldap\_user\_search  
some thing like this OU=employees,OU=users,OU=,DC=,DC=,DC=com and  
OU=employees,OU=users,OU=,DC=,DC=comcast,DC=com but its not accepting the settings is it possible to add multiple user searches.

Thanks,  
Rakesh Boinapally

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [June 2, 2022, 4:25pm UTC](https://forum.ansible.com/t/question-on-configuring-multiple-ldap-user-search-using-awx-awx-tower-settings/36655/2 "2022-06-02T16:25:09Z")

</div>

In the help bubble for user search it says: “If multiple search queries need to be supported use of “LDAPUnion” is possible. See the documentation for details”.  
The docs being referred to are located at [https://docs.ansible.com/automation-controller/latest/html/administration/ldap\_auth.html](https://docs.ansible.com/automation-controller/latest/html/administration/ldap_auth.html)  
If you search for LDAP USER SEARCH on that page and then scroll down a tad there is a note that says:  
For multiple search queries, the proper syntax is:  
[  
[  
“OU=Users,DC=northamerica,DC=acme,DC=com”,  
“SCOPE\_SUBTREE”,  
“(sAMAccountName=%(user)s)”  
],  
[  
“OU=Users,DC=apac,DC=corp,DC=com”,  
“SCOPE\_SUBTREE”,  
“(sAMAccountName=%(user)s)”  
],  
[  
“OU=Users,DC=emea,DC=corp,DC=com”,  
“SCOPE\_SUBTREE”,  
“(sAMAccountName=%(user)s)”  
]  
]

Give that syntax a try and let us know if that works for you.

-John

---

<div class="post-metadata">

**Author:** ![rake](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@rake](https://forum.ansible.com/u/rake)\
**Post date:** [June 3, 2022, 5:17am UTC](https://forum.ansible.com/t/question-on-configuring-multiple-ldap-user-search-using-awx-awx-tower-settings/36655/3 "2022-06-03T05:17:51Z")

</div>

I’m looking more around how can i add multiple ldap user search through awx.awx.tower\_settings ansible module.  
I did try to add it but had issues.

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [June 9, 2022, 1:50pm UTC](https://forum.ansible.com/t/question-on-configuring-multiple-ldap-user-search-using-awx-awx-tower-settings/36655/4 "2022-06-09T13:50:12Z")

</div>

Ah, I usually have a hard time representing arrays of arrays in yml format myself so I tend to use json format like:

- **awx** \*\*. **awx**.settings\*\*:  
**settings** :  
**AUTH\_LDAP\_USER\_SEARCH** : [  
[“OU=Users,DC=northamerica,DC=acme,DC=com”, “SCOPE\_SUBTREE”, “(sAMAccountName=%(user)s)”],  
[“OU=Users,DC=apac,DC=corp,DC=com”, “SCOPE\_SUBTREE”, “(sAMAccountName=%(user)s)”],  
[“OU=Users,DC=emea,DC=corp,DC=com”, “SCOPE\_SUBTREE”, “(sAMAccountName=%(user)s)”]  
]

Let us know if that works for you.

-John

---

<div class="post-metadata">

**Author:** ![rake](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@rake](https://forum.ansible.com/u/rake)\
**Post date:** [June 10, 2022, 7:50am UTC](https://forum.ansible.com/t/question-on-configuring-multiple-ldap-user-search-using-awx-awx-tower-settings/36655/5 "2022-06-10T07:50:57Z")

</div>

Tried this its not accepting at the syntax level only

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [June 10, 2022, 9:39am UTC](https://forum.ansible.com/t/question-on-configuring-multiple-ldap-user-search-using-awx-awx-tower-settings/36655/6 "2022-06-10T09:39:47Z")

</div>

What is the error you are getting? And what version of Ansible/AWX are you using?

-John

---

<div class="post-metadata">

**Author:** ![rake](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@rake](https://forum.ansible.com/u/rake)\
**Post date:** [June 10, 2022, 9:45am UTC](https://forum.ansible.com/t/question-on-configuring-multiple-ldap-user-search-using-awx-awx-tower-settings/36655/7 "2022-06-10T09:45:57Z")

</div>

Following is the error that I’m receiving.  
ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:  
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.  
did not find expected key

The error appears to be in ‘/home/rakeshcomcast/awx-testing/awx-deployer/awx-configure.yml’: line 110, column 10, but may  
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

AUTH\_LDAP\_USER\_SEARCH:[  
[“OU=Users,OU=Corporate,DC=cable,DC=comcast,DC=com”,“SCOPE\_SUBTREE”,“(sAMAccountName=%(user)s)”],  
^ here

Following is the ansible version ansible [core 2.12.6]

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [June 10, 2022, 9:53am UTC](https://forum.ansible.com/t/question-on-configuring-multiple-ldap-user-search-using-awx-awx-tower-settings/36655/8 "2022-06-10T09:53:44Z")

</div>

Do you have a space between AUTH\_LDAP\_USER\_SEARCH: and the opening 'square bracket?  
If not that could be the issue.

If so, I am on ansible 2.9 and I don’t have a problem with the OU line you have above. Could you try sending the entire task (masking out anything private)?  
Sometimes the line/column number point to the wrong place if the error is syntax related.

-John

---

<div class="post-metadata">

**Author:** ![rake](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@rake](https://forum.ansible.com/u/rake)\
**Post date:** [June 10, 2022, 10:29am UTC](https://forum.ansible.com/t/question-on-configuring-multiple-ldap-user-search-using-awx-awx-tower-settings/36655/9 "2022-06-10T10:29:37Z")

</div>

Tried that option to below is the exact one still having same error

AUTH\_LDAP\_USER\_SEARCH: [  
[“OU=Users,OU=Corporate,DC=cable,DC=comcast,DC=com”,“SCOPE\_SUBTREE”,“(sAMAccountName=%(user)s)”]  
[“OU=employees,OU=users,OU=india,DC=apac,DC=comcast,DC=com”,“SCOPE\_SUBTREE”,“(sAMAccountName=%(user)s)”]  
]

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [June 10, 2022, 10:32am UTC](https://forum.ansible.com/t/question-on-configuring-multiple-ldap-user-search-using-awx-awx-tower-settings/36655/10 "2022-06-10T10:32:21Z")

</div>

There is a , missing at the end of the first OU line. It should be:

AUTH\_LDAP\_USER\_SEARCH: [  
[“OU=Users,OU=Corporate,DC=cable,DC=comcast,DC=com”,“SCOPE\_SUBTREE”,“(sAMAccountName=%(user)s)”],

[“OU=employees,OU=users,OU=india,DC=apac,DC=comcast,DC=com”,“SCOPE\_SUBTREE”,“(sAMAccountName=%(user)s)”]  
]

Let me know if that resolves the issue.

---

<div class="post-metadata">

**Author:** ![rake](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@rake](https://forum.ansible.com/u/rake)\
**Post date:** [June 10, 2022, 10:35am UTC](https://forum.ansible.com/t/question-on-configuring-multiple-ldap-user-search-using-awx-awx-tower-settings/36655/11 "2022-06-10T10:35:47Z")

</div>

Sorry some how i deleted added that , back and still having same error  
ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:  
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.  
did not find expected key

The error appears to be in ‘/home/rakeshcomcast/awx-testing/awx-deployer/awx-configure.yml’: line 110, column 10, but may  
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

AUTH\_LDAP\_USER\_SEARCH: [  
[“OU=Users,OU=Corporate,DC=cable,DC=comcast,DC=com”,“SCOPE\_SUBTREE”,“(sAMAccountName=%(user)s)”],  
^ here

AUTH\_LDAP\_USER\_SEARCH: [  
[“OU=Users,OU=Corporate,DC=cable,DC=comcast,DC=com”,“SCOPE\_SUBTREE”,“(sAMAccountName=%(user)s)”],  
[“OU=employees,OU=users,OU=india,DC=apac,DC=comcast,DC=com”,“SCOPE\_SUBTREE”,“(sAMAccountName=%(user)s)”]  
]

---

<div class="post-metadata">

**Author:** ![rake](https://avatars.discourse-cdn.com/v4/letter/r/8e8cbc/32.png) [@rake](https://forum.ansible.com/u/rake)\
**Post date:** [June 10, 2022, 10:37am UTC](https://forum.ansible.com/t/question-on-configuring-multiple-ldap-user-search-using-awx-awx-tower-settings/36655/12 "2022-06-10T10:37:08Z")

</div>

I also saw some thing like this in following article [https://django-auth-ldap.readthedocs.io/en/latest/authentication.html](https://django-auth-ldap.readthedocs.io/en/latest/authentication.html)

```auto
import ldap
from django_auth_ldap.config import LDAPSearch, LDAPSearchUnion

AUTH_LDAP_USER_SEARCH = LDAPSearchUnion(
    LDAPSearch("ou=users,dc=example,dc=com", ldap.SCOPE_SUBTREE, "(uid=%(user)s)"),
    LDAPSearch("ou=otherusers,dc=example,dc=com", ldap.SCOPE_SUBTREE, "(uid=%(user)s)"),
)

```

```auto
Is it possible to use above syntax in ansible awx.awx.settings

```

```auto

```

---

<div class="post-metadata">

**Author:** ![awx\_release](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@awx\_release](https://forum.ansible.com/u/awx_release)\
**Post date:** [June 10, 2022, 12:57pm UTC](https://forum.ansible.com/t/question-on-configuring-multiple-ldap-user-search-using-awx-awx-tower-settings/36655/13 "2022-06-10T12:57:43Z")

</div>

That last code snippet is python and can’t be used directly by the module in an ansible playbook, the module would have to be altered in order to use something like that.

However, the module seems to be able to already handle this Here is my sample playbook that works for me:
