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

ldap: make sure realm is set #7690

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/providers/ldap/sdap_async_users.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ int sdap_save_user(TALLOC_CTX *memctx,
size_t c;
char *p1;
char *p2;
char *new_upn;
char *new_upn = NULL;
bool is_posix = true;

DEBUG(SSSDBG_TRACE_FUNC, "Save user\n");
Expand Down Expand Up @@ -278,8 +278,10 @@ int sdap_save_user(TALLOC_CTX *memctx,
&samaccountname);
if (ret == EOK) {
ret = ENOENT;
new_upn = talloc_asprintf(memctx, "%s@%s", samaccountname,
dom->realm);
if (dom->realm != NULL) {
alexey-tikhonov marked this conversation as resolved.
Show resolved Hide resolved
new_upn = talloc_asprintf(memctx, "%s@%s", samaccountname,
dom->realm);
}
if (new_upn != NULL){
ret = sysdb_attrs_add_string(user_attrs,
SYSDB_CANONICAL_UPN, new_upn);
Expand Down
71 changes: 71 additions & 0 deletions src/tests/system/tests/test_ad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"""
SSSD AD Provider Test Cases

:requirement: ad
"""

from __future__ import annotations

import pytest
from sssd_test_framework.roles.ad import AD
from sssd_test_framework.roles.client import Client
from sssd_test_framework.roles.generic import GenericADProvider
from sssd_test_framework.topology import KnownTopologyGroup


@pytest.mark.topology(KnownTopologyGroup.AnyAD)
@pytest.mark.ticket(jira="RHEL-65848", gh=7690)
@pytest.mark.parametrize("method", ["su", "ssh"])
@pytest.mark.importance("high")
def test_ad__user_authentication_when_provider_is_set_to_ldap_with_gss_spnego(
client: Client, provider: GenericADProvider, method: str
):
"""
:title: Login to AD when id_provider is set to ldap
:setup:
1. Add AD user
2. Update sssd.conf with 'id_provider = ldap', 'ldap_schema = ad',
'ldap_id_use_start_tls = false', 'auth_provider = ad' and
'ldap_sasl_mech = gssspengo' and Start SSSD
:steps:
1. Check authentication of the user
:expectedresults:
1. Authentication is successful
:customerscenario: False
"""
provider.user("user1").add()

client.sssd.config.remove_option("domain/test", "id_provider")

configurations = {
"id_provider": "ldap",
"ldap_schema": "ad",
"ldap_id_use_start_tls": "False",
"auth_provider": "ad",
"ldap_referrals": "False",
"ldap_sasl_mech": "GSS-SPNEGO",
"ldap_id_mapping": "True",
}

for key, value in configurations.items():
client.sssd.domain[key] = value

# id_provider = ldap will not add them automatically if they are not
# defined on the server side.
client.sssd.nss["default_shell"] = "/bin/bash"
client.sssd.nss["override_homedir"] = "/home/%u"

if isinstance(provider, AD):
dns_parameter = "ad.test"
else:
dns_parameter = "samba.test"
client.sssd.domain["krb5_realm"] = f"{dns_parameter.upper()}"
client.sssd.domain["dns_discovery_domain"] = f"{dns_parameter}"

client.sssd.start()

assert client.auth.parametrize(method).password("user1", "Secret123"), "User user1 failed login!"

log_str = client.fs.read("/var/log/sssd/krb5_child.log")
assert hasattr(provider.host, "domain"), "Host does not have 'domain' attribute!"
assert f"UPN [user1@{provider.host.domain}]" in log_str, f"'UPN [user1@{provider.host.domain}]' not in logs!"
Loading