public void ResetPassword(string password, AuthenticationOption option, string objectNotFoundExceptionText) { using (DirectorySearcher searcher = new DirectorySearcher()) { DirectoryEntry searchRoot = new DirectoryEntry(); searchRoot.Path = option.BuildLDAPPath(); searchRoot.Username = option.ServiceAccountName; searchRoot.Password = option.ServiceAccountPwd; searchRoot.AuthenticationType = option.GetAuthenticationType(); searcher.Filter = option.BuildSearchFilter(); searcher.PageSize = 1000; searcher.SearchScope = SearchScope.Subtree; searcher.SearchRoot = searchRoot; SearchResultCollection searchResult = searcher.FindAll(); if (searchResult != null && searchResult.Count == 1) { searchResult[0].GetDirectoryEntry().Invoke("SetPassword", new object[] { password }); } else { throw new Exception(objectNotFoundExceptionText); } } }
public bool SetStringValue(string attrName, string attrValue, AuthenticationOption option, SearchResultOption searchOption) { using (DirectorySearcher searcher = new DirectorySearcher()) { try { DirectoryEntry searchRoot = new DirectoryEntry(); searchRoot.Path = option.BuildLDAPPath(); searchRoot.Username = option.ServiceAccountName; searchRoot.Password = option.ServiceAccountPwd; searchRoot.AuthenticationType = option.GetAuthenticationType(); searcher.Filter = option.BuildSearchFilter(); searcher.PageSize = 1000; searcher.PropertiesToLoad.Add(attrName); searcher.SearchScope = SearchScope.Subtree; searcher.SearchRoot = searchRoot; SearchResultCollection searchResult = searcher.FindAll(); switch (searchOption) { case SearchResultOption.FindTheFirstOne: if (searchResult != null && searchResult.Count > 0) { DirectoryEntry de = searchResult[0].GetDirectoryEntry(); de.Properties[attrName].Value = attrValue; de.CommitChanges(); } break; case SearchResultOption.FindTheOnlyOne: if (searchResult != null && searchResult.Count == 1) { DirectoryEntry de = searchResult[0].GetDirectoryEntry(); de.Properties[attrName].Value = attrValue; de.CommitChanges(); } else { return(false); } break; case SearchResultOption.FindAll: default: throw new NotImplementedException(); } } catch (Exception) { return(false); } } return(true); }
// Constructor. internal SecurityIdentity(String accountName, AuthenticationOption authenticationLevel, int authenticationService, ImpersonationLevelOption impersonationLevel) { this.accountName = accountName; this.authenticationLevel = authenticationLevel; this.authenticationService = authenticationService; this.impersonationLevel = impersonationLevel; }
public ApplicationAccessControlAttribute(bool val) { this._val = val; this._authLevel = ~AuthenticationOption.Default; this._impLevel = ~ImpersonationLevelOption.Default; if (this._val) { this._checkLevel = AccessChecksLevelOption.ApplicationComponent; } else { this._checkLevel = AccessChecksLevelOption.Application; } }
public async Task UpdateAuthenticationOption_ReturnsNotFoundStatusCode() { //Arrange var newUnit = new AuthenticationOption { AuthenticationProviderKey = "Test10", AuthenticationOptionId = 80 }; var content = Utilities.GetRequestContent(newUnit); //Act var response = await _client.PutAsync(UriForTests.UpdateUri(ControllerNames.AuthenticationOptions), content); //Assert Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); }
public async Task UpdateAuthenticationOption_ReturnSuccessStatusCode() { //Arrange var newUnit = new AuthenticationOption { AuthenticationProviderKey = "Test10", AuthenticationOptionId = 10 }; var content = Utilities.GetRequestContent(newUnit); //Act var response = await _client.PutAsync(UriForTests.UpdateUri(ControllerNames.AuthenticationOptions), content); //Assert response.EnsureSuccessStatusCode(); }
/// <include file='doc\SecurityAttribute.uex' path='docs/doc[@for="ApplicationAccessControlAttribute.ApplicationAccessControlAttribute1"]/*' /> public ApplicationAccessControlAttribute(bool val) { _val = val; _authLevel = (AuthenticationOption)(-1); _impLevel = (ImpersonationLevelOption)(-1); if (_val) { _checkLevel = AccessChecksLevelOption.ApplicationComponent; } else { _checkLevel = AccessChecksLevelOption.Application; } }
/// <summary> /// Ctor. /// </summary> /// <param name="optionsAccessor">Jwt settings.</param> /// <param name="userRepository">Repository for obtaining users.</param> public TokenController(IOptions <AuthenticationOption> optionsAccessor, IUserRepository userRepository) { _userRepository = Check.NotNull(userRepository, nameof(userRepository)); _params = optionsAccessor.Value; }
public void ResetPassword(string dn, string password, AuthenticationOption option) { DirectoryEntry user = new DirectoryEntry(string.Format("LDAP://{0}", dn), option.ServiceAccountName, option.ServiceAccountPwd, option.GetAuthenticationType()); user.Invoke("SetPassword", password); }
public void ResetPassword(string password, AuthenticationOption option) { ResetPassword(password, option, string.Empty); }