def get_users_accounts()

in ees_microsoft_outlook/microsoft_exchange_server_user.py [0:0]


    def get_users_accounts(self, users):
        """Fetch user account from exchange server
        :param users: Fetch users from Exchange Active Directory
        Returns:
            users_accounts: List of all user accounts
        """
        users_accounts = []
        try:
            # Logic to establish secure connection when SSL is enabled into exchange server host name
            if self.config.get_value("microsoft_exchange.secure_connection"):
                global global_dns_name, global_ssl_certificate_path
                global_dns_name = self.config.get_value("microsoft_exchange.server")
                global_ssl_certificate_path = self.config.get_value(
                    "microsoft_exchange.certificate_path"
                )

                BaseProtocol.HTTP_ADAPTER_CLS = RootCAAdapter
            else:
                BaseProtocol.HTTP_ADAPTER_CLS = NoVerifyHTTPAdapter
            for user in users:
                if "searchResRef" not in user["type"]:
                    credentials = Credentials(
                        self.config.get_value("microsoft_exchange.username"),
                        self.config.get_value("microsoft_exchange.password"),
                    )
                    config = Configuration(
                        server=self.config.get_value("microsoft_exchange.server"),
                        credentials=credentials,
                        retry_policy=FaultTolerance(max_wait=900),
                    )
                    user_account = Account(
                        primary_smtp_address=user["attributes"]["mail"],
                        config=config,
                        access_type=IMPERSONATION,
                    )
                    users_accounts.append(user_account)
            return users_accounts
        except Exception as exception:
            raise Exception(
                f"Error while fetching users account from exchange server. Error: {exception}"
            )