/// <summary>
        /// update
        /// </summary>
        /// <param name="id">id</param>
        /// <param name="resource">resource</param>
        /// <returns>ApiResultLDAPEntity</returns>
        public ApiResultLDAPEntity UpdateLdapObject(long?id, LDAPEntity resource)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new ApiException(400, "Missing required parameter 'id' when calling UpdateLdapObject");
            }

            // verify the required parameter 'resource' is set
            if (resource == null)
            {
                throw new ApiException(400, "Missing required parameter 'resource' when calling UpdateLdapObject");
            }


            var path = "/ldapObjects/{id}";

            path = path.Replace("{format}", "json");
            path = path.Replace("{" + "id" + "}", ApiClient.ParameterToString(id));

            var    queryParams  = new Dictionary <String, String>();
            var    headerParams = new Dictionary <String, String>();
            var    formParams   = new Dictionary <String, String>();
            var    fileParams   = new Dictionary <String, FileParameter>();
            String postBody     = null;

            postBody = ApiClient.Serialize(resource);                                     // http body (model) parameter

            // authentication setting, if any
            String[] authSettings = new String[] { "FortifyToken" };

            // make the HTTP request
            IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings);

            if (((int)response.StatusCode) >= 400)
            {
                throw new ApiException((int)response.StatusCode, "Error calling UpdateLdapObject: " + response.Content, response.Content);
            }
            else if (((int)response.StatusCode) == 0)
            {
                throw new ApiException((int)response.StatusCode, "Error calling UpdateLdapObject: " + response.ErrorMessage, response.ErrorMessage);
            }

            return((ApiResultLDAPEntity)ApiClient.Deserialize(response.Content, typeof(ApiResultLDAPEntity), response.Headers));
        }
Exemple #2
0
        private async Task <IdentityResult> RegisterRemoteCredentialsAsync(string username, string domain, LDAPEntity credential)
        {
            var user = new Usuario
            {
                Name               = credential.Name.Trim(),
                Surname            = credential.Surname.Trim(),
                UserName           = $@"{domain}\{username}",
                NormalizedUserName = $@"{domain}\{username}".ToUpper(),
                Email              = credential.Email,
                NormalizedEmail    = credential.Email?.ToUpper(),
                EmailConfirmed     = true,
                StatusId           = (int)EnumUsuarioStatus.Pendente
            };

            var result = await _userManager.CreateAsync(user);

            if (result.Succeeded)
            {
                await _userManager.SetLockoutEnabledAsync(user, false);

                await _userManager.AddClaimAsync(user, new Claim(IdentityServerApiConstants.StandardClaims.JobRole, credential.JobRole));

                await _userManager.AddClaimAsync(user, new Claim(IdentityServerApiConstants.StandardClaims.Department, credential.Department));
            }

            return(result);
        }