/// <summary>
        /// Constructs an IntuneClient object which can be used to make requests to Intune services.
        /// </summary>
        /// <param name="configProperties">Configuration properties for this class.</param>
        /// <param name="authClient">Authorization Client.</param>
        /// <param name="locationProvider">Service Location provider to be used for service discovery.</param>
        /// <param name="httpClient">HttpClient to use for all requests.</param>
        /// <param name="trace">Trace</param>
        public IntuneClient(Dictionary <string, string> configProperties, MsalClient authClient, IIntuneServiceLocationProvider locationProvider, IHttpClient httpClient = null, TraceSource trace = null)
        {
            // Required Parameters/Dependencies
            if (configProperties == null)
            {
                throw new ArgumentNullException(nameof(configProperties));
            }

            if (locationProvider == null)
            {
                throw new ArgumentNullException(nameof(locationProvider));
            }
            this.locationProvider = locationProvider;
            if (authClient == null)
            {
                throw new ArgumentNullException(nameof(authClient));
            }
            this.authClient = authClient;

            // Optional Prameters/Dependencies
            configProperties.TryGetValue("INTUNE_RESOURCE_URL", out intuneResourceUrl);
            if (string.IsNullOrWhiteSpace(intuneResourceUrl))
            {
                intuneResourceUrl = DEFAULT_INTUNE_RESOURCE_URL;
            }

            if (trace != null)
            {
                this.trace = trace;
            }

            this.httpClient = httpClient ?? new HttpClient(new System.Net.Http.HttpClient());
        }
예제 #2
0
        public IntuneRevocationClient(
            Dictionary <string, string> configProperties,
            TraceSource trace          = null,
            IIntuneClient intuneClient = null)
        {
            // Required Parameters
            if (configProperties == null)
            {
                throw new ArgumentNullException(nameof(configProperties));
            }

            configProperties.TryGetValue("PROVIDER_NAME_AND_VERSION", out this.providerNameAndVersion);
            if (string.IsNullOrWhiteSpace(providerNameAndVersion))
            {
                throw new ArgumentNullException(nameof(providerNameAndVersion));
            }

            // Optional Parameters
            if (trace != null)
            {
                this.trace = trace;
            }

            configProperties.TryGetValue("PkiConnectorFEServiceVersion", out this.serviceVersion);
            serviceVersion = serviceVersion ?? DEFAULT_SERVICE_VERSION;

            // Dependencies
            var msalClient = new MsalClient(
                // Required
                configProperties,
                // Overrides
                trace: trace
                );
            var adalClient = new AdalClient(
                // Required
                configProperties,
                // Overrides
                trace: trace
                );

            this.intuneClient = intuneClient ?? new IntuneClient(
                // Required
                configProperties,
                // Overrides
                trace: trace,
                // Dependencies
                authClient: msalClient,
                locationProvider: new IntuneServiceLocationProvider(
                    // Required
                    configProperties,
                    // Overrides
                    trace: trace,
                    // Dependencies
                    adalClient: adalClient,
                    msalClient: msalClient
                    )
                );
        }
        public IntuneServiceLocationProvider(Dictionary <string, string> configProperties, MsalClient msalClient, AdalClient adalClient, IHttpClient httpClient = null, TraceSource trace = null)
        {
            // Required Parameters
            if (configProperties == null)
            {
                throw new ArgumentNullException(nameof(configProperties));
            }

            configProperties.TryGetValue("TENANT", out tenant);
            if (string.IsNullOrWhiteSpace(tenant))
            {
                throw new ArgumentNullException(nameof(tenant));
            }

            if (msalClient == null)
            {
                throw new ArgumentNullException(nameof(msalClient));
            }
            this.msalClient = msalClient;

            if (adalClient == null)
            {
                throw new ArgumentNullException(nameof(msalClient));
            }
            this.adalClient = adalClient;

            // Optional Parameters
            if (trace != null)
            {
                this.trace = trace;
            }

            configProperties.TryGetValue("AAD_GRAPH_API_VERSION", out aadGraphApiVersion);
            if (string.IsNullOrWhiteSpace(aadGraphApiVersion))
            {
                aadGraphApiVersion = DEFAULT_AADGRAPH_VERSION;
            }

            configProperties.TryGetValue("MS_GRAPH_API_VERSION", out msGraphApiVersion);
            if (string.IsNullOrWhiteSpace(msGraphApiVersion))
            {
                msGraphApiVersion = DEFAULT_MSGRAPH_VERSION;
            }

            configProperties.TryGetValue("AAD_GRAPH_RESOURCE_URL", out aadGraphResourceUrl);
            if (string.IsNullOrWhiteSpace(aadGraphResourceUrl))
            {
                aadGraphResourceUrl = DEFAULT_AADGRAPH_RESOURCE_URL;
            }

            configProperties.TryGetValue("MSAL_GRAPH_RESOURCE_URL", out msalGraphResourceUrl);
            if (string.IsNullOrWhiteSpace(msalGraphResourceUrl))
            {
                msalGraphResourceUrl = DEFAULT_MSGRAPH_RESOURCE_URL;
            }

            configProperties.TryGetValue("INTUNE_APP_ID", out intuneAppId);
            if (string.IsNullOrWhiteSpace(intuneAppId))
            {
                intuneAppId = DEFAULT_INTUNE_APP_ID;
            }

            // Dependencies
            this.httpClient = httpClient ?? new HttpClient(new System.Net.Http.HttpClient());
        }