Skip to content

Commit

Permalink
azure_rm_aduser, azure_rm_aduser_info - Add support for `mobile_p…
Browse files Browse the repository at this point in the history
…hone` (#1623)

* Added mobile phone for user

* Update plugins/modules/azure_rm_aduser.py

Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com>

* Update plugins/modules/azure_rm_aduser_info.py

Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com>

---------

Co-authored-by: Marcel Novotny <marceln@xcroco.com>
Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 8, 2024
1 parent 2c9aeab commit 960024d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
23 changes: 21 additions & 2 deletions plugins/modules/azure_rm_aduser.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
- The primary email address of the user.
- Used when either creating or updating a user account.
type: str
mobile_phone:
description:
- Mobile phone number of the user.
- Used when either creating or updating a user account.
type: str
mail_nickname:
description:
- The mail alias for the user.
Expand Down Expand Up @@ -165,6 +170,7 @@
user_type: "Member"
usage_location: "US"
mail: "{{ user_principal_name }}@contoso.com"
mobile_phone: "+1234567890123"
company_name: 'Test Company'
on_premises_extension_attributes:
extension_attribute1: "test_extension_attribute1"
Expand Down Expand Up @@ -226,6 +232,12 @@
returned: always
type: str
sample: Member
mobile_phone:
description:
- The mobile phone number of the user.
type: str
returned: always
sample: '+1234567890123'
company_name:
description:
- The name of the company that the user is associated with.
Expand Down Expand Up @@ -281,6 +293,7 @@ def __init__(self):
user_type=dict(type='str'),
mail=dict(type='str'),
company_name=dict(type='str'),
mobile_phone=dict(type='str'),
on_premises_extension_attributes=dict(type='dict', aliases=['extension_attributes'])
)

Expand All @@ -303,6 +316,7 @@ def __init__(self):
self.user_type = None
self.mail = None
self.company_name = None
self.mobile_phone = None
self.on_premises_extension_attributes = None
self.log_path = None
self.log_mode = None
Expand Down Expand Up @@ -373,6 +387,8 @@ def exec_module(self, **kwargs):
should_update = True
if should_update or self.mail_nickname and ad_user.mail_nickname != self.mail_nickname:
should_update = True
if should_update or self.mobile_phone and ad_user.mobile_phone != self.mobile_phone:
should_update = True
if should_update or self.company_name and ad_user.company_name != self.company_name:
should_update = True
if should_update or (
Expand Down Expand Up @@ -468,6 +484,7 @@ def to_dict(self, object):
account_enabled=object.account_enabled,
user_type=object.user_type,
company_name=object.company_name,
mobile_phone=object.mobile_phone,
on_premises_extension_attributes=self.on_premises_extension_attributes_to_dict(object.on_premises_extension_attributes)
)

Expand All @@ -484,6 +501,7 @@ async def update_user(self, ad_user, password_profile, extension_attributes):
user_principal_name=self.user_principal_name,
mail_nickname=self.mail_nickname,
company_name=self.company_name,
mobile_phone=self.mobile_phone,
on_premises_extension_attributes=extension_attributes
)
return await self._client.users.by_user_id(ad_user.id).patch(body=request_body)
Expand All @@ -507,6 +525,7 @@ async def create_user(self, extension_attributes):
user_type=self.user_type,
mail=self.mail,
company_name=self.company_name,
mobile_phone=self.mobile_phone,
on_premises_extension_attributes=extension_attributes
)
return await self._client.users.post(body=request_body)
Expand All @@ -518,7 +537,7 @@ async def get_user(self, object):
request_configuration = UsersRequestBuilder.UsersRequestBuilderGetRequestConfiguration(
query_parameters=UsersRequestBuilder.UsersRequestBuilderGetQueryParameters(
select=["accountEnabled", "displayName", "mail", "mailNickname", "id", "userPrincipalName", "userType",
"onPremisesImmutableId", "usageLocation", "givenName", "surname", "companyName",
"onPremisesImmutableId", "usageLocation", "givenName", "surname", "companyName", "mobilePhone",
"OnPremisesExtensionAttributes"]
),
)
Expand All @@ -530,7 +549,7 @@ async def get_users_by_filter(self, filter):
query_parameters=UsersRequestBuilder.UsersRequestBuilderGetQueryParameters(
filter=filter,
select=["accountEnabled", "displayName", "mail", "mailNickname", "id", "userPrincipalName",
"userType", "onPremisesImmutableId", "usageLocation", "givenName", "surname", "companyName",
"userType", "onPremisesImmutableId", "usageLocation", "givenName", "surname", "companyName", "mobilePhone",
"OnPremisesExtensionAttributes"],
count=True
),
Expand Down
11 changes: 9 additions & 2 deletions plugins/modules/azure_rm_aduser_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@
returned: always
type: str
sample: Member
mobile_phone:
description:
- The mobile phone number of the user.
type: str
returned: always
sample: '+1234567890123'
company_name:
description:
- The name of the company that the user is associated with.
Expand Down Expand Up @@ -262,14 +268,15 @@ def to_dict(self, object):
account_enabled=object.account_enabled,
user_type=object.user_type,
company_name=object.company_name,
mobile_phone=object.mobile_phone,
on_premises_extension_attributes=self.on_premises_extension_attributes_to_dict(object.on_premises_extension_attributes)
)

async def get_user(self, object):
request_configuration = UsersRequestBuilder.UsersRequestBuilderGetRequestConfiguration(
query_parameters=UsersRequestBuilder.UsersRequestBuilderGetQueryParameters(
select=["accountEnabled", "displayName", "mail", "mailNickname", "id", "userPrincipalName",
"userType", "companyName", "onPremisesExtensionAttributes"]
"userType", "companyName", "mobilePhone", "onPremisesExtensionAttributes"]
),
)
return await self._client.users.by_user_id(object).get(request_configuration=request_configuration)
Expand All @@ -278,7 +285,7 @@ async def get_users(self):
request_configuration = UsersRequestBuilder.UsersRequestBuilderGetRequestConfiguration(
query_parameters=UsersRequestBuilder.UsersRequestBuilderGetQueryParameters(
select=["accountEnabled", "displayName", "mail", "mailNickname", "id", "userPrincipalName",
"userType", "companyName", "onPremisesExtensionAttributes"]
"userType", "companyName", "mobilePhone", "onPremisesExtensionAttributes"]
),
)
users = []
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/targets/azure_rm_aduser/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
user_type: "Member"
usage_location: "US"
mail: "{{ user_name }}@{{ domain }}"
mobile_phone: "+12345678912"
company_name: "Test Company"
on_premises_extension_attributes:
extension_attribute1: "test_extension_attribute1"
Expand All @@ -40,6 +41,7 @@
user_type: "Member"
usage_location: "US"
mail: "{{ user_name }}@{{ domain }}"
mobile_phone: "+12345678912"
company_name: "Test Company"
on_premises_extension_attributes:
extension_attribute1: "test_extension_attribute1"
Expand Down

0 comments on commit 960024d

Please sign in to comment.