Skip to content

Commit

Permalink
roles: added upn parameter when adding ad users, value defaults to fqn
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Lavu authored and pbrezina committed Oct 1, 2024
1 parent 2e375d8 commit 3c40cf3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sssd_test_framework/roles/ad.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ def add(
gecos: str | None = None,
shell: str | None = None,
email: str | None = None,
upn: str | None = None,
) -> ADUser:
"""
Create new AD user.
Expand All @@ -753,12 +754,17 @@ def add(
:type shell: str | None, optional
:param email: Email, defaults to None (= user@domain)
:type email: str | None, optional
:param upn: User principal name, defaults to None
:type upn: str | None, optional
:return: Self.
:rtype: ADUser
"""
if email is None:
email = f"{self.name}@{self.host.domain}"

if upn is None:
upn = f"{self.name}@{self.host.domain}"

unix_attrs = {
"uid": self.name,
"uidNumber": uid,
Expand All @@ -777,6 +783,7 @@ def add(
"EmailAddress": (self.cli.option.PLAIN, email),
"GivenName": (self.cli.option.PLAIN, "dummyfirstname"),
"Surname": (self.cli.option.PLAIN, "dummylastname"),
"UserPrincipalName": (self.cli.option.PLAIN, upn),
}

self._add(attrs)
Expand All @@ -794,6 +801,7 @@ def modify(
email: str | DeleteAttribute | None = None,
givenname: str | DeleteAttribute | None = None,
surname: str | DeleteAttribute | None = None,
upn: DeleteAttribute | None = None,
) -> ADUser:
"""
Modify existing AD user.
Expand All @@ -819,6 +827,8 @@ def modify(
:type givenname: str | DeleteAttribute | None, optional
:param surname: Sur name of user, defaults to None
:type surname: str | DeleteAttribute | None, optional
:param upn: User principal name, defaults to None
:type upn: str | None, optional
:return: Self.
:rtype: ADUser
"""
Expand All @@ -834,6 +844,7 @@ def modify(
"emailAddress": email,
"GivenName": givenname,
"SurName": surname,
"UserPrincipalName": upn,
}
all_attrs = {**unix_attrs, **ad_attrs}

Expand Down

0 comments on commit 3c40cf3

Please sign in to comment.