Skip to content

Commit

Permalink
Merge branch 'dev' into v1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred-sun authored May 12, 2021
2 parents 17a0163 + 24b08f7 commit 41ec878
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
9 changes: 5 additions & 4 deletions plugins/module_utils/azure_rm_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1427,19 +1427,20 @@ def __init__(self, auth_source=None, profile=None, subscription_id=None, client_
else:
self._adfs_authority_url = self.credentials.get('adfs_authority_url')

# get resource from cloud environment
self._resource = self._cloud_environment.endpoints.active_directory_resource_id

if self.credentials.get('credentials') is not None:
# AzureCLI credentials
self.azure_credentials = self.credentials['credentials']
elif self.credentials.get('client_id') is not None and \
self.credentials.get('secret') is not None and \
self.credentials.get('tenant') is not None:

graph_resource = self._cloud_environment.endpoints.active_directory_graph_resource_id
rm_resource = self._cloud_environment.endpoints.resource_manager
self.azure_credentials = ServicePrincipalCredentials(client_id=self.credentials['client_id'],
secret=self.credentials['secret'],
tenant=self.credentials['tenant'],
cloud_environment=self._cloud_environment,
resource=graph_resource if self.is_ad_resource else rm_resource,
verify=self._cert_validation_mode == 'validate')

elif self.credentials.get('ad_user') is not None and \
Expand All @@ -1449,7 +1450,7 @@ def __init__(self, auth_source=None, profile=None, subscription_id=None, client_

self.azure_credentials = self.acquire_token_with_username_password(
self._adfs_authority_url,
self._resource,
self._cloud_environment.endpoints.active_directory_resource_id,
self.credentials['ad_user'],
self.credentials['password'],
self.credentials['client_id'],
Expand Down
20 changes: 10 additions & 10 deletions plugins/modules/azure_rm_aduser.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
pass


class AzureRMADUserInfo(AzureRMModuleBase):
class AzureRMADUser(AzureRMModuleBase):
def __init__(self):

self.module_arg_spec = dict(
Expand Down Expand Up @@ -271,13 +271,13 @@ def __init__(self):
required_together = [['attribute_name', 'attribute_value']]
required_one_of = [['odata_filter', 'attribute_name', 'object_id', 'user_principal_name']]

super(AzureRMADUserInfo, self).__init__(derived_arg_spec=self.module_arg_spec,
supports_check_mode=False,
supports_tags=False,
mutually_exclusive=mutually_exclusive,
required_together=required_together,
required_one_of=required_one_of,
is_ad_resource=True)
super(AzureRMADUser, self).__init__(derived_arg_spec=self.module_arg_spec,
supports_check_mode=False,
supports_tags=False,
mutually_exclusive=mutually_exclusive,
required_together=required_together,
required_one_of=required_one_of,
is_ad_resource=True)

def exec_module(self, **kwargs):

Expand Down Expand Up @@ -310,7 +310,7 @@ def exec_module(self, **kwargs):
should_update = True
if should_update or self.user_type and ad_user.user_type != self.user_type:
should_update = True
if should_update or self.account_enabled and ad_user.account_enabled != self.account_enabled:
if should_update or self.account_enabled is not None and ad_user.account_enabled != self.account_enabled:
should_update = True
if should_update or self.display_name and ad_user.display_name != self.display_name:
should_update = True
Expand Down Expand Up @@ -416,7 +416,7 @@ def to_dict(self, object):


def main():
AzureRMADUserInfo()
AzureRMADUser()


if __name__ == '__main__':
Expand Down

0 comments on commit 41ec878

Please sign in to comment.