예제 #1
0
        /// <summary>
        /// LDAP library constructior where all the class variables are initialized
        /// The variables not specified in definition will be set at default values.
        /// </summary>
        /// <param name="adminUser">Admin user</param>
        /// <param name="adminMode">Admin User</param>
        /// <param name="ldapServer">LDAP Server with port</param>
        /// <param name="ldapSearchBaseDn">Base DN where start the search.</param>
        /// <param name="authType"></param>
        /// <param name="loggerType">Mode to log</param>
        /// <param name="logPath">Path of the logger File</param>
        public LdapManager(ILdapUser adminUser, LDAPAdminMode adminMode,
            string ldapServer,
            string ldapSearchBaseDn,
            AuthType authType,
            LoggerType loggerType,
            string logPath
            )
        {
            _configRepository = LdapConfigRepositoryFactory.GetConfigRepository();
            try
            {
                _configRepository.BasicLdapConfig(adminUser,adminMode, ldapServer, ldapSearchBaseDn, authType, loggerType, logPath);
                _logger = LoggerFactory.GetLogger(_configRepository.GetWriteLogFlag(), _configRepository.GetLogPath());
            }
            catch (ArgumentNullException)
            {
                _ldapCurrentState = LdapState.LdapLibraryInitError;
                throw;
            }

            _adminModeChecker = new LdapAdminModeChecker(_configRepository);

            CommonInitOperations();
            _ldapCurrentState = LdapState.LdapLibraryInitSuccess;
        }
예제 #2
0
        /// <summary>
        /// LDAP library constructior where all the class variables are initialized
        /// The variables not specified in definition will be set at default values.
        /// </summary>
        /// <param name="adminUser">Admin user</param>
        /// <param name="adminMode">Admin User</param>
        /// <param name="ldapServer">LDAP Server with port</param>
        /// <param name="ldapSearchBaseDn">Base DN where start the search.</param>
        /// <param name="authType"></param>
        /// <param name="loggerType">Mode to log</param>
        /// <param name="logPath">Path of the logger File</param>
        public LdapManager(ILdapUser adminUser, LDAPAdminMode adminMode,
                           string ldapServer,
                           string ldapSearchBaseDn,
                           AuthType authType,
                           LoggerType loggerType,
                           string logPath
                           )
        {
            _configRepository = LdapConfigRepositoryFactory.GetConfigRepository();
            try
            {
                _configRepository.BasicLdapConfig(adminUser, adminMode, ldapServer, ldapSearchBaseDn, authType, loggerType, logPath);
                _logger = LoggerFactory.GetLogger(_configRepository.GetWriteLogFlag(), _configRepository.GetLogPath());
            }
            catch (ArgumentNullException)
            {
                _ldapCurrentState = LdapState.LdapLibraryInitError;
                throw;
            }

            _adminModeChecker = new LdapAdminModeChecker(_configRepository);

            CommonInitOperations();
            _ldapCurrentState = LdapState.LdapLibraryInitSuccess;
        }
예제 #3
0
        /// <summary>
        /// More detailed contructor that user the default constructor and the addictionalLDAPInformation method
        /// </summary>
        public LdapManager(ILdapUser adminUser,
                           LDAPAdminMode adminMode,
                           string ldapServer,
                           string ldapSearchBaseDn,
                           AuthType authType,
                           bool secureSocketLayerFlag,
                           bool transportSocketLayerFlag,
                           bool clientCertificateFlag,
                           string clientCertificatePath,
                           LoggerType loggerType,
                           string logPath,
                           string userObjectClass,
                           string matchFieldUsername,
                           TimeSpan connectionTimeout)
            : this(adminUser, adminMode,
                   ldapServer,
                   ldapSearchBaseDn,
                   authType,
                   loggerType, logPath)
        {
            try
            {
                _configRepository.AdditionalLdapConfig(secureSocketLayerFlag, transportSocketLayerFlag,
                                                       clientCertificateFlag, clientCertificatePath, userObjectClass,
                                                       matchFieldUsername, connectionTimeout);
            }
            catch (ArgumentNullException e)
            {
                _ldapCurrentState = LdapState.LdapLibraryInitError;
                _logger.Write(_logger.BuildLogMessage(e.Message, _ldapCurrentState));
                throw;
            }

            CommonInitOperations();
            _ldapCurrentState = LdapState.LdapLibraryInitSuccess;
            _logger.Write(_logger.BuildLogMessage("", _ldapCurrentState));
        }
예제 #4
0
 public bool ChangeUserPassword(ILdapUser user, string newPwd)
 {
     _ldapCurrentState = _manageLdapUser.ChangeUserPassword(user, newPwd);
     return LdapStateUtils.ToBoolean(_ldapCurrentState);
 }
예제 #5
0
 public bool SearchUsers(List<string> otherReturnedAttributes, string[] searchedUsers,
     out List<ILdapUser> searchResult)
 {
     _ldapCurrentState = _manageLdapUser.SearchUsers(otherReturnedAttributes, searchedUsers, out searchResult);
     return LdapStateUtils.ToBoolean(_ldapCurrentState);
 }
예제 #6
0
 public bool DeleteUser(ILdapUser user)
 {
     _ldapCurrentState = _manageLdapUser.DeleteUser(user);
     return LdapStateUtils.ToBoolean(_ldapCurrentState);
 }
예제 #7
0
 public bool ModifyUserAttribute(DirectoryAttributeOperation operationType, ILdapUser user, string attributeName,
     string attributeValue)
 {
     _ldapCurrentState = _manageLdapUser.ModifyUserAttribute(operationType, user, attributeName, attributeValue);
     return LdapStateUtils.ToBoolean(_ldapCurrentState);
 }
예제 #8
0
 /// <summary>
 /// Convert the state to a boolean
 /// </summary>
 /// <param name="state">Input State</param>
 /// <returns>        
 /// TRUE - success state
 /// FALSE - error state
 /// </returns>
 public static bool ToBoolean(LdapState state)
 {
     return state == LdapState.LdapConnectionSuccess || state == LdapState.LdapLibraryInitSuccess ||
            state == LdapState.LdapUserManipulatorSuccess;
 }
예제 #9
0
 public bool CreateUser(ILdapUser newUser)
 {
     _ldapCurrentState = _manageLdapUser.CreateUser(newUser);
     return LdapStateUtils.ToBoolean(_ldapCurrentState);
 }
예제 #10
0
 public bool CreateUser(ILdapUser newUser)
 {
     _ldapCurrentState = _manageLdapUser.CreateUser(newUser);
     return(LdapStateUtils.ToBoolean(_ldapCurrentState));
 }
예제 #11
0
 public string BuildLogMessage(string message, LdapState state)
 {
     return String.Format("{0} - {1}", DateTime.Now.ToString(DateFormat, CultureInfo.InvariantCulture),
         _ldapErrors[state](message));
 }
예제 #12
0
 public bool Connect(NetworkCredential credential)
 {
     _ldapCurrentState = _connector.Connect(credential);
     return(LdapStateUtils.ToBoolean(_ldapCurrentState));
 }
예제 #13
0
 public bool Connect()
 {
     _ldapCurrentState = _connector.Connect();
     return LdapStateUtils.ToBoolean(_ldapCurrentState);
 }
예제 #14
0
 public bool Connect()
 {
     _ldapCurrentState = _connector.Connect();
     return(LdapStateUtils.ToBoolean(_ldapCurrentState));
 }
예제 #15
0
 public bool SearchAllNodes(IList <string> otherReturnedAttributes, out IList <ILdapUser> searchResult)
 {
     _ldapCurrentState = _searcher.SearchAllNodes(otherReturnedAttributes, out searchResult);
     return(LdapStateUtils.ToBoolean(_ldapCurrentState));
 }
예제 #16
0
 public bool ChangeUserPassword(ILdapUser user, string newPwd)
 {
     _ldapCurrentState = _manageLdapUser.ChangeUserPassword(user, newPwd);
     return(LdapStateUtils.ToBoolean(_ldapCurrentState));
 }
예제 #17
0
 public bool ModifyUserAttribute(DirectoryAttributeOperation operationType, ILdapUser user, string attributeName,
                                 string attributeValue)
 {
     _ldapCurrentState = _manageLdapUser.ModifyUserAttribute(operationType, user, attributeName, attributeValue);
     return(LdapStateUtils.ToBoolean(_ldapCurrentState));
 }
예제 #18
0
 public bool DeleteUser(ILdapUser user)
 {
     _ldapCurrentState = _manageLdapUser.DeleteUser(user);
     return(LdapStateUtils.ToBoolean(_ldapCurrentState));
 }
예제 #19
0
 public bool Connect(NetworkCredential credential)
 {
     _ldapCurrentState = _connector.Connect(credential);
     return LdapStateUtils.ToBoolean(_ldapCurrentState);
 }
예제 #20
0
 public string BuildLogMessage(string message, LdapState state)
 {
     return(String.Format("{0} - {1}", DateTime.Now.ToString(DateFormat, CultureInfo.InvariantCulture),
                          _ldapErrors[state](message)));
 }
예제 #21
0
        /// <summary>
        /// More detailed contructor that user the default constructor and the addictionalLDAPInformation method
        /// </summary>
        public LdapManager(ILdapUser adminUser, LDAPAdminMode adminMode,string ldapServer,string ldapSearchBaseDn,AuthType authType,bool secureSocketLayerFlag,bool transportSocketLayerFlag,bool clientCertificateFlag,string clientCertificatePath,LoggerType loggerType,string logPath,string userObjectClass,string matchFieldUsername)
            : this(adminUser, adminMode,
                ldapServer,
                ldapSearchBaseDn,
                authType,
                loggerType, logPath)
        {
            try
            {
                _configRepository.AdditionalLdapConfig(secureSocketLayerFlag, transportSocketLayerFlag,
                    clientCertificateFlag, clientCertificatePath, userObjectClass,
                    matchFieldUsername);
            }
            catch (ArgumentNullException e)
            {
                _ldapCurrentState = LdapState.LdapLibraryInitError;
                _logger.Write(_logger.BuildLogMessage(e.Message, _ldapCurrentState));
                throw;
            }

            CommonInitOperations();
            _ldapCurrentState = LdapState.LdapLibraryInitSuccess;
            _logger.Write(_logger.BuildLogMessage("", _ldapCurrentState));
        }
예제 #22
0
 /// <summary>
 /// Convert the state to a boolean
 /// </summary>
 /// <param name="state">Input State</param>
 /// <returns>
 /// TRUE - success state
 /// FALSE - error state
 /// </returns>
 public static bool ToBoolean(LdapState state)
 {
     return(state == LdapState.LdapConnectionSuccess || state == LdapState.LdapLibraryInitSuccess ||
            state == LdapState.LdapUserManipulatorSuccess);
 }