示例#1
0
        public void AuthenticateTest(ActiveDirectoryAuthenticatorTestArgs args)
        {
            XElement x = new XElement("Authentication");

            x.Add(new XAttribute("AuthID", "testid"));
            x.Add(new XAttribute("Domain", args.Domain));
            ActiveDirectoryAuthenticator           adauth = new ActiveDirectoryAuthenticator(x);
            ActiveDirectoryAuthenticatorTestSource source = new ActiveDirectoryAuthenticatorTestSource();

            adauth.PasswordSource = source;
            adauth.UsernameSource = source;
            source.Username       = args.AuthUser;
            source.SecurePassword = GetSecureStringFromString(args.AuthPassword);
            adauth.RequiredGroups = args.Groups;
            AuthState state = adauth.Authenticate();

            NUnit.Framework.Assert.AreEqual(args.ExpectedResult, state);
        }
        public void IsMemberOfGroupsTest(ActiveDirectoryMethodsTestArgs args)
        {
            ActiveDirectoryAuthenticatorTestArgs authargs = args.AuthArgs;
            XElement x = new XElement("Authentication");

            x.Add(new XAttribute("AuthID", "testid"));
            x.Add(new XAttribute("Domain", authargs.Domain));
            ActiveDirectoryAuthenticator           adauth = new ActiveDirectoryAuthenticator(x);
            ActiveDirectoryAuthenticatorTestSource source = new ActiveDirectoryAuthenticatorTestSource();

            adauth.PasswordSource = source;
            adauth.UsernameSource = source;
            source.Username       = authargs.AuthUser;
            source.SecurePassword = GetSecureStringFromString(authargs.AuthPassword);
            adauth.RequiredGroups = args.AuthArgs.Groups;
            adauth.Authenticate();
            bool result = ActiveDirectoryMethods.IsUserMemberOfGroups(adauth.Context, args.UserName, args.Groups);

            Assert.AreEqual(args.ExpectedResult, result);
        }