/// <summary>
 /// Check the validity of parameters
 ///
 /// * Check if clientCertificatePath, userObjectClass, matchFieldUsername are null or empty
 ///
 /// Used in AdditionalLdapConfig
 ///
 /// Can throw an ArgumentNullException
 /// </summary>
 /// <param name="clientCertificatePath"></param>
 /// <param name="userObjectClass"></param>
 /// <param name="matchFieldUsername"></param>
 private void AddictionalLdapConfigValidator(string clientCertificatePath, string userObjectClass, string matchFieldUsername)
 {
     if (LdapParameterChecker.ParametersIsNullOrEmpty(new[] { userObjectClass, matchFieldUsername }) || String.IsNullOrEmpty(clientCertificatePath) && GetClientCertificateFlag() == true)
     {
         throw new ArgumentNullException(String.Format(CompleteConfigNullParametersErrorMessage,
                                                       _adminUser, clientCertificatePath, userObjectClass, matchFieldUsername));
     }
 }
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        protected void StandardConnect(NetworkCredential credential)
        {
            if (LdapParameterChecker.ParametersIsNullOrEmpty(new [] { credential.UserName }))
            {
                throw new InvalidCredentialException("Username cannot be null or empty");
            }
            if (LdapParameterChecker.ParametersIsNullOrEmpty(new [] { credential.Password }))
            {
                throw new InvalidCredentialException("Password cannot be null or empty");
            }

            _ldapConnection = LdapConnectionFactory.GetLdapConnection(_configRepository);
            _ldapConnection.Bind(credential);
        }
예제 #3
0
 public LdapUser(string userDn, string userCn, string userSn, Dictionary <string, List <string> > otherAttribute)
 {
     if (!LdapParameterChecker.ParametersIsNullOrEmpty(new[] { userDn, userSn, userCn }))
     {
         _sn = userSn;
         _dn = userDn;
         _cn = userCn;
         _otherAttributes = otherAttribute == null
             ? new Dictionary <string, List <string> >()
             : new Dictionary <string, List <string> >(otherAttribute);
     }
     else
     {
         throw new ArgumentException("The first 3 parameters cannot be null or empty");
     }
 }
예제 #4
0
 public void ParametersNullAndEmpty()
 {
     Assert.IsTrue(LdapParameterChecker.ParametersIsNullOrEmpty(new[] { "", null }));
 }
예제 #5
0
 public void ParametersNull()
 {
     Assert.IsTrue(LdapParameterChecker.ParametersIsNullOrEmpty(new[] { null, Test }));
 }
예제 #6
0
 public void ParametersNotNull()
 {
     Assert.IsFalse(LdapParameterChecker.ParametersIsNullOrEmpty(new[] { Test, Test }));
 }