Skip to content

Commit 149b7b7

Browse files
author
Dan Lavu
committed
adding sssd ldap_provider() to optionally ad or ipa to use ldap
1 parent 8147b99 commit 149b7b7

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

sssd_test_framework/utils/sssd.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,62 @@ def mkhomedir(self) -> None:
951951
self.sssd.authselect.select("sssd", ["with-mkhomedir"])
952952
self.sssd.svc.start("oddjobd.service")
953953

954+
def ldap_provider(
955+
self,
956+
server: str,
957+
naming_context: str,
958+
bind_user_dn: str,
959+
bind_password: str,
960+
subids: bool = False,
961+
cacert: str = "/etc/ipa/ca.crt",
962+
tls_reqcert: str = "demand",
963+
) -> None:
964+
"""
965+
Configure SSSD to use the ldap_provider to connect to IPA or AD.
966+
This is an alternate configuration and should rarely be used. LDAP
967+
provider test cases should cover these scenarios.
968+
969+
:param server: LDAP server.
970+
:type server: str
971+
:param naming_context: Naming context
972+
:type naming_context: str
973+
:param bind_user_dn: Bind user distinguished name.
974+
:type bind_user_dn: str
975+
:param bind_password: Bind password.
976+
:type bind_password: str
977+
:param subids: Enable subids, optional
978+
:type subids: bool
979+
:param cacert: CA certificate, defaults to'/etc/ipa/ca.crt'
980+
:type cacert: str
981+
:param tls_reqcert: Force TLS, defaults to 'demand'
982+
:type tls_reqcert: str
983+
"""
984+
self.sssd.domain.clear()
985+
self.sssd.domain.update(
986+
id_provider="ldap",
987+
auth_provider="ldap",
988+
ldap_uri=f"ldap://{server}",
989+
ldap_search_base=f"cn=accounts,{naming_context.strip()}",
990+
ldap_tls_reqcert=tls_reqcert,
991+
ldap_tls_cacert=cacert,
992+
ldap_default_bind_dn=bind_user_dn,
993+
ldap_default_authtok_type="password",
994+
ldap_default_authtok=bind_password,
995+
)
996+
997+
if subids:
998+
self.sssd.domain.update(
999+
ldap_subid_ranges_search_base=f"cn=subids,cn=accounts,{naming_context.strip()}",
1000+
ldap_subuid_object_class="ipasubordinateidentry",
1001+
ldap_subuid_count="ipaSubUidCount",
1002+
ldap_subgid_count="ipaSubGidCount",
1003+
ldap_subuid_number="ipaSubUidNumber",
1004+
ldap_subgid_number="ipaSubGidNumber",
1005+
ldap_subid_range_owner="ipaOwner",
1006+
)
1007+
1008+
self.sssd.config_apply()
1009+
9541010
def proxy(
9551011
self,
9561012
proxy: Literal["files", "ldap"] = "files",

0 commit comments

Comments
 (0)