Skip to content

Commit 3fc7780

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

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

sssd_test_framework/utils/sssd.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,78 @@ 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+
ssl: bool = False,
964+
config: dict[str, str] | None = None,
965+
) -> None:
966+
"""
967+
Configure SSSD to use the ldap_provider to connect to IPA or AD.
968+
This is an alternate configuration and should rarely be used. LDAP
969+
provider test cases should cover these scenarios.
970+
971+
:param server: LDAP server.
972+
:type server: str
973+
:param naming_context: Naming context
974+
:type naming_context: str
975+
:param bind_user_dn: Bind user distinguished name.
976+
:type bind_user_dn: str
977+
:param bind_password: Bind password.
978+
:type bind_password: str
979+
:param subids: Enable subids, optional
980+
:type subids: bool
981+
:param cacert: CA certificate, defaults to'/etc/ipa/ca.crt'
982+
:type cacert: str
983+
:param tls_reqcert: Force TLS, defaults to 'demand'
984+
:type tls_reqcert: str
985+
:param ssl: Enable SSL, defaults to 'False'
986+
:type ssl: bool
987+
:param config: Additional configuration, optional
988+
:type config; dict[str, str] | None
989+
"""
990+
self.sssd.domain.clear()
991+
self.sssd.domain.update(
992+
id_provider="ldap",
993+
auth_provider="ldap",
994+
ldap_uri=f"ldap://{server}",
995+
ldap_search_base=f"cn=accounts,{naming_context.strip()}",
996+
ldap_tls_reqcert=tls_reqcert,
997+
ldap_tls_cacert=cacert,
998+
ldap_default_bind_dn=bind_user_dn,
999+
ldap_default_authtok_type="password",
1000+
ldap_default_authtok=bind_password,
1001+
)
1002+
1003+
if ssl:
1004+
self.sssd.domain.update(
1005+
ldap_uri=f"ldaps://{server}",
1006+
ldap_id_use_start_tls="False",
1007+
)
1008+
1009+
if subids:
1010+
self.sssd.domain.update(
1011+
ldap_subid_ranges_search_base=f"cn=subids,cn=accounts,{naming_context.strip()}",
1012+
ldap_subuid_object_class="ipasubordinateidentry",
1013+
ldap_subuid_count="ipaSubUidCount",
1014+
ldap_subgid_count="ipaSubGidCount",
1015+
ldap_subuid_number="ipaSubUidNumber",
1016+
ldap_subgid_number="ipaSubGidNumber",
1017+
ldap_subid_range_owner="ipaOwner",
1018+
)
1019+
1020+
if config is not None and isinstance(config, dict):
1021+
for key, value in config.items():
1022+
self.sssd.domain[key] = value
1023+
1024+
self.sssd.config_apply()
1025+
9541026
def proxy(
9551027
self,
9561028
proxy: Literal["files", "ldap"] = "files",

0 commit comments

Comments
 (0)