# Authc in AD domain "prod" and Authz in AD domain "dev"

**URL:** <https://forum.opensearch.org/t/authc-in-ad-domain-prod-and-authz-in-ad-domain-dev/10567>\
**Category:** Security\
**Tags:** troubleshoot\
**Created:** [August 10, 2022, 9:56am UTC](https://forum.opensearch.org/t/authc-in-ad-domain-prod-and-authz-in-ad-domain-dev/10567 "2022-08-10T09:56:51Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![LGR](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@LGR](https://forum.opensearch.org/u/LGR)\
**Post date:** [August 10, 2022, 9:56am UTC](https://forum.opensearch.org/t/authc-in-ad-domain-prod-and-authz-in-ad-domain-dev/10567/1 "2022-08-10T09:56:52Z")

</div>

Hi everyboy,

i want to Authc in a prod domain but Authz in another domain (there’s a “trust” between the domains)

Authc and Authz works flawlessly if i use the same domain for both config.

Does i have to use this

roles\_from\_another\_ldap:  
description: “Authorize via another Active Directory”

in place of

authz:  
roles\_from\_myldap:  
description: “Authorize via LDAP or Active Directory”

---

<div class="post-metadata">

**Author:** ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/pablo/32/10363_2.png) [@pablo](https://forum.opensearch.org/u/pablo)\
**Post date:** [August 10, 2022, 10:53am UTC](https://forum.opensearch.org/t/authc-in-ad-domain-prod-and-authz-in-ad-domain-dev/10567/2 "2022-08-10T10:53:08Z")

</div>

@LGR `roles_from_myldap` and `roles_from_another_ldap` are just lables.  
You don’t need to configure a second authz domain.

If you configure two authz domains then the authorization process will be executed in the order they’re configured in the authz section. This is a logical `OR` operation, so the first hit will stop the process.  
If the authz match will be found in the first domain then the second one won’t be checked.

---

<div class="post-metadata">

**Author:** ![LGR](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@LGR](https://forum.opensearch.org/u/LGR)\
**Post date:** [August 10, 2022, 11:15am UTC](https://forum.opensearch.org/t/authc-in-ad-domain-prod-and-authz-in-ad-domain-dev/10567/3 "2022-08-10T11:15:30Z")

</div>

@pablo

thanks for the reply.

i was meaning something like this :

```auto
authc:
      ldap:
        description: "Authenticate via LDAP or Active Directory"
        authentication_backend:
          # LDAP authentication backend (authenticate users against a LDAP or Active Directory)
          type: ldap
          config:
            hosts:
            - prod.com:389
            bind_dn: CN=someone,DC=prod,DC=com
            password: apassword
            userbase: 'ou=users,dc=prod,dc=com'
            usersearch: '(userPrincipalName={0})'
            username_attribute: userPrincipalName
    authz:
      roles_from_myldap:
        description: "Authorize via LDAP or Active Directory"
        authorization_backend:
          # LDAP authorization backend (gather roles from a LDAP or Active Directory, you have to configure the above LDAP authentication backend settings too)
          type: ldap
          config:
            hosts:
            - dev.com:389
            bind_dn: CN=someone,DC=dev,DC=com
            password: apassword
            rolebase: 'OU=Groups,DC=dev,DC=com'
            rolesearch: '(Member={0})'
            userroleattribute: null
            userrolename: disabled
            rolename: cn 
            resolve_nested_roles: true
            userbase: "ou=users,dc=prod,dc=com"
            usersearch: '(userPrincipalName={0})'
         

```

so it’ s supposed to work if the bind account in the authz section can access the the “prod” domain to “search” for the users

am i right?

already thanks for your time

---

<div class="post-metadata">

**Author:** ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/pablo/32/10363_2.png) [@pablo](https://forum.opensearch.org/u/pablo)\
**Post date:** [August 10, 2022, 11:29am UTC](https://forum.opensearch.org/t/authc-in-ad-domain-prod-and-authz-in-ad-domain-dev/10567/4 "2022-08-10T11:29:17Z")

</div>

@LGR That should work. Did you test that already?

---

<div class="post-metadata">

**Author:** ![LGR](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@LGR](https://forum.opensearch.org/u/LGR)\
**Post date:** [August 10, 2022, 11:35am UTC](https://forum.opensearch.org/t/authc-in-ad-domain-prod-and-authz-in-ad-domain-dev/10567/5 "2022-08-10T11:35:17Z")

</div>

working on it… i’ll let you known if it’s works

---

<div class="post-metadata">

**Author:** ![LGR](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@LGR](https://forum.opensearch.org/u/LGR)\
**Post date:** [August 10, 2022, 3:43pm UTC](https://forum.opensearch.org/t/authc-in-ad-domain-prod-and-authz-in-ad-domain-dev/10567/6 "2022-08-10T15:43:26Z")

</div>

we have try several things but without success.

our last try was to use ‘ObjectSid’ because when you add a “trusted” user account this what will be used to determine against which domain the credential has to be checked.

```auto
authc:
      ldap:
        description: "Authenticate via LDAP or Active Directory"
        authentication_backend:
          # LDAP authentication backend (authenticate users against a LDAP or Active Directory)
          type: ldap
          config:
            hosts:
            - prod.com:389
            bind_dn: CN=someone,DC=prod,DC=com
            password: apassword
            userbase: 'ou=users,dc=prod,dc=com'
            usersearch: '(sAMAccountName={0})'
            username_attribute: sAMAccountName
    authz:
      roles_from_myldap:
        description: "Authorize via LDAP or Active Directory"
        authorization_backend:
          # LDAP authorization backend (gather roles from a LDAP or Active Directory, you have to configure the above LDAP authentication backend settings too)
          type: ldap
          config:
            hosts:
            - dev.com:389
            bind_dn: CN=someone,DC=dev,DC=com
            password: apassword
            rolebase: 'OU=Groups,DC=dev,DC=com'
            rolesearch: '(Member={2})'
            userroleattribute: ObjectSid
            userrolename: disabled
            rolename: cn 
            resolve_nested_roles: true
            userbase: "CN=ForeignSecurityPrincipals,DC=dev,DC=com"
            usersearch: '(ObjectSid={0})'

```

still no clue until now  
[ERROR][o.o.s.a.BackendRegistry] [hostname] Cannot retrieve roles for User [name=aUser@prod.com, backend\_roles=, requestedTenant=null]  
from ldap due to OpenSearchSecurityException[OpenSearchSecurityException[No user ‘CN=aUser,DC=prod,DC=com’ found]];  
nested: OpenSearchSecurityException[No user ‘CN=aUser,DC=prod,DC=com’ found];  
org.opensearch.OpenSearchSecurityException: OpenSearchSecurityException[No user ‘CN=aUser,DC=prod,DC=com’ found] at com.amazon.dlic.auth.ldap.backend.LDAPAuthorizationBackend.fillRoles(LDAPAuthorizationBackend.java:945) ~[opensearch-security-1.3.2.0.jar:1.3.2.0]

i’ve to mention that we’re still running opensearch 1.3.2

regards

---

<div class="post-metadata">

**Author:** ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/pablo/32/10363_2.png) [@pablo](https://forum.opensearch.org/u/pablo)\
**Post date:** [August 10, 2022, 3:59pm UTC](https://forum.opensearch.org/t/authc-in-ad-domain-prod-and-authz-in-ad-domain-dev/10567/7 "2022-08-10T15:59:58Z")

</div>

@LGR Have you tried to use the `ldapsearch` tool to verify the binding and search OU?

Does user “someone” directly under `prod.dc`?

---

<div class="post-metadata">

**Author:** ![LGR](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@LGR](https://forum.opensearch.org/u/LGR)\
**Post date:** [August 10, 2022, 5:04pm UTC](https://forum.opensearch.org/t/authc-in-ad-domain-prod-and-authz-in-ad-domain-dev/10567/8 "2022-08-10T17:04:22Z")

</div>

yes about “someone” : i’ve a bind account for Prod and a bind account for Dev.  
my perception is no matter what, opensearch is looking for the user DN in the domain mentioned in the authz.

i will do a few test with a ldapsearch tool alike

thanks for your time

edit : to be complete = \> we have 1Forest/1domain trusting 1forest/1domain

- external trust
- domain-wide authentication

---

<div class="post-metadata">

**Author:** ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/pablo/32/10363_2.png) [@pablo](https://forum.opensearch.org/u/pablo)\
**Post date:** [August 11, 2022, 2:18pm UTC](https://forum.opensearch.org/t/authc-in-ad-domain-prod-and-authz-in-ad-domain-dev/10567/9 "2022-08-11T14:18:06Z")

</div>

@LGR Have you tried to `userrolename` instead of `rolesearch`?

```auto
    authz:
      roles_from_myldap:
        description: "Authorize via LDAP or Active Directory"
        authorization_backend:
          type: ldap
          config:
            hosts:
            - prod.com:389
            bind_dn: CN=someone,DC=prod,DC=com
            password: password

            userrolename: memberOf
            rolename: cn 
            resolve_nested_roles: true

            userbase: 'ou=users,dc=prod,dc=com'
            usersearch: '(sAMAccountName={0})'

```

I’ll try to test your approach with different ADs and configured trust.

---

<div class="post-metadata">

**Author:** ![LGR](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@LGR](https://forum.opensearch.org/u/LGR)\
**Post date:** [August 18, 2022, 6:39am UTC](https://forum.opensearch.org/t/authc-in-ad-domain-prod-and-authz-in-ad-domain-dev/10567/10 "2022-08-18T06:39:26Z")

</div>

i’ll try it (today probably) and let you know if it help or not.

regards

---

<div class="post-metadata">

**Author:** ![LGR](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@LGR](https://forum.opensearch.org/u/LGR)\
**Post date:** [August 18, 2022, 2:57pm UTC](https://forum.opensearch.org/t/authc-in-ad-domain-prod-and-authz-in-ad-domain-dev/10567/11 "2022-08-18T14:57:54Z")

</div>

if authc appends in dc=prod,dc=com and authz appends in dc=dev,dc=com =\> it doesn’t work.

something with the trust. Maybe it’s simply not supported…

regards

---

<div class="post-metadata">

**Author:** ![LGR](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@LGR](https://forum.opensearch.org/u/LGR)\
**Post date:** [September 12, 2022, 11:01am UTC](https://forum.opensearch.org/t/authc-in-ad-domain-prod-and-authz-in-ad-domain-dev/10567/12 "2022-09-12T11:01:52Z")

</div>

FYI

I got the last week contact with AWS (Specialist Solutions Architect - Analytics  
Amazon Web Services) about this. The question about “trust” and one AD to authenticate /another one to authorize will be asked to the security team.

Waiting news.

cya

---

<div class="post-metadata">

**Author:** ![LGR](https://avatars.discourse-cdn.com/v4/letter/l/f14d63/32.png) [@LGR](https://forum.opensearch.org/u/LGR)\
**Post date:** [December 8, 2022, 2:16pm UTC](https://forum.opensearch.org/t/authc-in-ad-domain-prod-and-authz-in-ad-domain-dev/10567/13 "2022-12-08T14:16:52Z")

</div>

still no news until now, i will ask an update.  
Meanwhile, we are using authc and authz within the same AD domain.

but i’ve another question =\> another topic
