/// <summary> /// Send a GET request to the route {serverProfile}/{catalogType}/[controller]/[action] of LDAP Web Api Directory controller. /// </summary> /// <param name="filterAttribute"><see cref="EntryAttribute"/> that will condition the search according to the <paramref name="filterValue"/>.</param> /// <param name="filterValue">The value that must be compared with the <paramref name="filterAttribute"/> in order to satisfy the search condition.</param> /// <param name="secondFilterAttribute">Second <see cref="EntryAttribute"/> that will condition the search according to the <paramref name="secondFilterValue"/>.</param> /// <param name="secondFilterValue">The value that must be compared with the <paramref name="secondFilterAttribute"/> in order to satisfy the search condition.</param> /// <param name="combineFilters">Whether it is combined in a conjunction or not the search filters.</param> /// <param name="requiredAttributes">The attributes that we want to obtain for each LDAP entry that was obtained as result of the search.</param> /// <param name="requestTag">Label that will identify the results of the operation.</param> /// <param name="setAuthorizationHeaderWithBearerToken">Whether or not to request and / or assign the access token in the authorization HTTP header.</param> /// <param name="cancellationToken">See <see cref="CancellationToken"/>.</param> /// <returns><see cref="IHttpResponse"/></returns> public async Task <IHttpResponse> SearchByFiltersAsync(EntryAttribute filterAttribute, string filterValue, EntryAttribute?secondFilterAttribute = null, string secondFilterValue = null, bool?combineFilters = null, RequiredEntryAttributes?requiredAttributes = null, string requestTag = null, bool setAuthorizationHeaderWithBearerToken = true, CancellationToken cancellationToken = default) { var uri = $"{WebApiBaseUrl}/api/{LDAPServerProfile}/{LDAPServerCatalogTypes.GetCatalogTypeName(UseLDAPServerGlobalCatalog)}/{ControllerNames.DirectoryController}/filterBy?filterAttribute={filterAttribute}&filterValue={filterValue}&secondFilterAttribute={GetOptionalEntryAttributeName(secondFilterAttribute)}&secondFilterValue={secondFilterValue}&combineFilters={GetOptionalBooleanValue(combineFilters)}&requiredAttributes={GetOptionalRequiredEntryAttributesName(requiredAttributes)}&requestTag={requestTag}"; using (var httpClient = await CreateHttpClient(setAuthorizationHeaderWithBearerToken)) { var responseMessage = await httpClient.GetAsync(uri, cancellationToken); if (!responseMessage.IsSuccessStatusCode) { return(await responseMessage.ToUnsuccessfulHttpResponseAsync()); } else { return(await responseMessage.ToSuccessfulHttpResponseAsync <LDAPSearchResult>()); } } }
/// <summary> /// Send a GET request to the route {serverProfile}/{catalogType}/[controller]/Groups/{identifier} of LDAP Web Api Directory controller. /// </summary> /// <param name="identifier">The value that must be compared with the <paramref name="identifierAttribute"/> in order to satisfy the search condition.</param> /// <param name="identifierAttribute"><see cref="EntryAttribute"/> that identifies an LDAP entry.</param> /// <param name="requiredAttributes">The attributes that we want to obtain from the LDAP entry as a result of the search.</param> /// <param name="requestTag">Label that will identify the results of the operation.</param> /// <param name="setAuthorizationHeaderWithBearerToken">Whether or not to request and / or assign the access token in the authorization HTTP header.</param> /// <param name="cancellationToken">See <see cref="CancellationToken"/>.</param> /// <returns><see cref="IHttpResponse"/></returns> public async Task <IHttpResponse> SearchByIdentifierAsync(string identifier, EntryAttribute?identifierAttribute, RequiredEntryAttributes?requiredAttributes = null, string requestTag = null, bool setAuthorizationHeaderWithBearerToken = true, CancellationToken cancellationToken = default) { var uri = $"{WebApiBaseUrl}/api/{LDAPServerProfile}/{LDAPServerCatalogTypes.GetCatalogTypeName(UseLDAPServerGlobalCatalog)}/{ControllerNames.DirectoryController}/Groups/{identifier}?identifierAttribute={GetOptionalEntryAttributeName(identifierAttribute)}&requiredAttributes={GetOptionalRequiredEntryAttributesName(requiredAttributes)}&requestTag={requestTag}"; using (var httpClient = await CreateHttpClient(setAuthorizationHeaderWithBearerToken)) { var responseMessage = await httpClient.GetAsync(uri, cancellationToken); if (!responseMessage.IsSuccessStatusCode) { return(await responseMessage.ToUnsuccessfulHttpResponseAsync()); } else { return(await responseMessage.ToSuccessfulHttpResponseAsync <LDAPSearchResult>()); } } }
/// <summary> /// Send a post request to LDAP Web Api Authentications controller. /// </summary> /// <param name="accountCredential">Account credentials or Network credentials</param> /// <param name="setAuthorizationHeaderWithBearerToken">Whether or not to request and / or assign the access token in the authorization HTTP header.</param> /// <param name="cancellationToken">See <see cref="CancellationToken"/>.</param> /// <returns></returns> public async Task <IHttpResponse> AccountAuthenticationAsync(DTO.LDAPAccountCredentials accountCredential, bool setAuthorizationHeaderWithBearerToken = true, CancellationToken cancellationToken = default) { var uri = $"{WebApiBaseUrl}/api/{LDAPServerProfile}/{LDAPServerCatalogTypes.GetCatalogTypeName(UseLDAPServerGlobalCatalog)}/{ControllerNames.AuthenticationsController}"; using (var httpClient = await CreateHttpClient(setAuthorizationHeaderWithBearerToken)) { var content = new ObjectContent <DTO.LDAPAccountCredentials>(accountCredential, new JsonMediaTypeFormatter()); var responseMessage = await httpClient.PostAsync(uri, content, cancellationToken); if (!responseMessage.IsSuccessStatusCode) { return(await responseMessage.ToUnsuccessfulHttpResponseAsync()); } else { return(await responseMessage.ToSuccessfulHttpResponseAsync <DTO.LDAPAccountAuthenticationStatus>()); } } }