コード例 #1
0
ファイル: ADOperation.cs プロジェクト: sagius-li/Lydia
        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);
                }
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 // Constructor.
 internal SecurityIdentity(String accountName,
                           AuthenticationOption authenticationLevel,
                           int authenticationService,
                           ImpersonationLevelOption impersonationLevel)
 {
     this.accountName           = accountName;
     this.authenticationLevel   = authenticationLevel;
     this.authenticationService = authenticationService;
     this.impersonationLevel    = impersonationLevel;
 }
コード例 #4
0
	// 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 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;
     }
 }
コード例 #7
0
ファイル: Update.cs プロジェクト: WombatWithBeard/ApiGateway
        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);
        }
コード例 #8
0
ファイル: Update.cs プロジェクト: WombatWithBeard/ApiGateway
        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();
        }
コード例 #9
0
        /// <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;
            }
        }
コード例 #10
0
 /// <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;
 }
コード例 #11
0
ファイル: ADOperation.cs プロジェクト: sagius-li/Lydia
        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);
        }
コード例 #12
0
ファイル: ADOperation.cs プロジェクト: sagius-li/Lydia
 public void ResetPassword(string password, AuthenticationOption option)
 {
     ResetPassword(password, option, string.Empty);
 }