public void ShouldDeleteUser() { var e = new AD_DeleteUserProperties { Cn = _user, Path = _path }; var result = LdapActiveDirectoryOperations.AD_DeleteUser(_connection, e); Assert.AreEqual(result.operationSuccessful, true); }
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); }
public void ShouldAddGroups() { var u = new AD_AddGroupsUserProperties { dn = _dn }; var e = new AD_AddGroupsProperties { groups = new[] { _groupDn } }; var result = LdapActiveDirectoryOperations.AD_AddGroups(_connection, u, e); Assert.AreEqual(result.operationSuccessful, true); }
public void ShouldRemoveUserFromGroup() { var u = new AD_RemoveFromGroupsTargetProperties { Dn = _dn }; var e = new AD_RemoveFromGroupsGroupProperties { Groups = new[] { _groupDn } }; Output result = LdapActiveDirectoryOperations.AD_RemoveFromGroups(_connection, u, e); Assert.IsTrue(result.operationSuccessful); }
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")); }
public void ShouldMoveUser() { var input = new MoveObject() { CN = "kk", Path = "kk", NewPath = "kk" }; var ret = LdapActiveDirectoryOperations.AD_MoveObject(_connection, input); // Also assert that copy of object is correct. Assert.AreEqual(ret.OperationSuccessful, true); }
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()); }
public void ShouldUpdateUser() { var user = new UpdateADuser { DN = _dn }; var attributes = new List <EntryAttribute> { new EntryAttribute { Attribute = AdUserAttribute.description, Value = "MattiMeikalainen", DataType = AttributeType.String } }; user.OtherAttributes = attributes.ToArray(); var result = LdapActiveDirectoryOperations.AD_UpdateUser(_connection, user); Assert.AreEqual(result.operationSuccessful, true); }
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); }
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); }
public void ShouldSearchUser() { var prop = new AD_SearchObjectProperties() { Filter = "(&(objectClass=user)(cn=" + _user + "))", Path = _path, PropertiesToLoad = new[] { "cn", "invalidProperty" } }; var ret = LdapActiveDirectoryOperations.AD_SearchObjects(_connection, prop); var cnValue = ret[0].GetPropertyStringValue("cn"); // Should return null. var nullValue = ret[0].GetPropertyStringValue("name"); Assert.AreEqual(cnValue, _user); Assert.AreEqual(nullValue, null); }
public void ShouldCreateUser() { var user = new CreateADuser { CN = _user, Path = _path }; var attributes = new List <EntryAttribute> { new EntryAttribute() { Attribute = AdUserAttribute.givenName, Value = "Matti", DataType = AttributeType.String } }; user.OtherAttributes = attributes.ToArray(); var flags = new List <ADFlag> { new ADFlag { FlagType = ADFlagType.ADS_UF_ACCOUNTDISABLE, Value = false }, new ADFlag { FlagType = ADFlagType.ADS_UF_NORMAL_ACCOUNT, Value = true } }; user.ADFlags = flags.ToArray(); var e = new AD_CreateUserProperties() { newPassword = "", setPassword = false }; var result = LdapActiveDirectoryOperations.AD_CreateUser(_connection, user, e); Assert.AreEqual(result.operationSuccessful, true); }
public void ShouldSetPassword() { var result = LdapActiveDirectoryOperations.AD_SetUserPassword(_passConnection); Assert.AreEqual(result.OperationSuccessful, true); }