示例#1
0
        /// <summary>
        /// Asynchronously get a collection of users that belong to the specified tenant identifier.
        /// </summary>
        /// <param name="tenantId">The tenant identifier.</param>
        /// <returns>
        /// A collection of users that belong to the specified tenant identifer.
        /// </returns>
        /// <exception cref="ArgumentNullException">tenantId</exception>
        public async Task <List <User> > GetUsersAsync(string tenantId)
        {
            Result <User> users;
            string        requestUri;

            if (string.IsNullOrEmpty(tenantId))
            {
                throw new ArgumentNullException("tenantId");
            }

            requestUri = string.Format(
                "{0}/{1}/users?api-version=1.6",
                Configuration.AzureADGraphAPIRoot,
                tenantId
                );

            users = await _comm.GetAsync <Result <User> >(
                requestUri,
                new MediaTypeWithQualityHeaderValue("application/json"),
                GetAADToken(tenantId).AccessToken,
                Guid.NewGuid().ToString()
                );

            return(users.Value);
        }
        /// <summary>
        /// Asynchronously gets a list of domains that belong to the specified customer identifier.
        /// </summary>
        /// <param name="customerId">The customer identifier.</param>
        /// <returns>
        /// A list of domains that belong to the specified customer identifier.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        /// customerId
        /// </exception>
        public async Task <List <Domain> > GetDomainsAsync(string customerId)
        {
            Result <Domain> domains;
            string          requestUri;

            if (string.IsNullOrEmpty(customerId))
            {
                throw new ArgumentNullException(nameof(customerId));
            }

            try
            {
                requestUri = $"{AppConfig.GraphUri}/{customerId}/domains?api-version=beta";

                domains = await _comm.GetAsync <Result <Domain> >(
                    requestUri,
                    new MediaTypeWithQualityHeaderValue("application/json"),
                    _token);

                return(domains.Value);
            }
            finally
            {
                domains = null;
            }
        }