public void ShouldFetchUser()
        {
            var e = new AD_FetchObjectProperties()
            {
                filter = "(&(objectClass=user)(cn=" + _user + "))",
                Path   = _path
            };
            var u      = LdapActiveDirectoryOperations.AD_FetchObjects(_connection, e);
            var result = u[0].GetProperty("cn");

            Assert.AreEqual(result[0], _user);
        }
Exemple #2
0
        public void GetPropertyLargeInteger_InvalidAttributeShouldThrowException()
        {
            var e = new AD_FetchObjectProperties()
            {
                Filter = "(&(objectClass=user)(cn=" + _user + "))",
                Path   = _path
            };

            // User.
            var u = LdapActiveDirectoryOperations.AD_FetchObjects(_connection, e);

            Assert.Throws <ArgumentException>(() => u[0].GetPropertyLargeInteger("fooBar"));
        }
Exemple #3
0
        public void ShouldGetUserLastLogonDateTime()
        {
            var e = new AD_FetchObjectProperties()
            {
                Filter = "(&(objectClass=user)(cn=" + _user + "))",
                Path   = _path
            };

            var expectedDateTime = DateTime.MinValue;

            var u      = LdapActiveDirectoryOperations.AD_FetchObjects(_connection, e);
            var result = u[0].GetPropertyDateTime("lastLogon");

            Assert.AreEqual(expectedDateTime.GetType(), result.GetType());
        }
Exemple #4
0
        public void ShouldGetUserAccountExpiresDateTime()
        {
            var e = new AD_FetchObjectProperties()
            {
                Filter = "(&(objectClass=user)(cn=" + _user + "))",
                Path   = _path
            };

            // User accountExpires = 0x7FFFFFFFFFFFFFFF -> DateTime should return DateTime.MaxValue.
            var expectedDateTime = DateTime.MaxValue;

            // User.
            var u      = LdapActiveDirectoryOperations.AD_FetchObjects(_connection, e);
            var result = u[0].GetAccountExpiresDateTime();

            Assert.AreEqual(expectedDateTime, result);
        }
Exemple #5
0
        public void ShouldGetPropertyLargeInteger()
        {
            var e = new AD_FetchObjectProperties()
            {
                Filter = "(&(objectClass=user)(cn=" + _user + "))",
                Path   = _path
            };

            // Assume the created test user has a default value of: accountExpires = 0x7FFFFFFFFFFFFFFF = 9223372036854775807.
            const long largeInt = 9223372036854775807;

            // User.
            var u      = LdapActiveDirectoryOperations.AD_FetchObjects(_connection, e);
            var result = (long)u[0].GetPropertyLargeInteger("accountExpires");

            Assert.AreEqual(largeInt, result);
        }