public void DeleteUserAttribute() { var user = new LdapUser(LdapUserDn, LdapUserCn, LdapUserSn, new Dictionary<string, List<string>> { {"description", new List<string> {"test description"}}, }); const string descriptionToDelete = "test description"; user.DeleteUserAttribute("description", descriptionToDelete); Console.WriteLine(user.GetUserAttribute("description")); Assert.IsTrue(!user.GetUserAttribute("description").Contains(descriptionToDelete)); Assert.IsTrue(user.GetUserAttribute("description").Count == 0); }
private LdapUser setupReadOnlyTestUser() { string userDN = "cn=Matteo,o=ApexNet,ou=People,dc=maxcrc,dc=com"; string userCN = "Matteo"; string userSN = "Paci"; LdapUser testLdapUser = new LdapUser(userDN, userCN, userSN, null); testLdapUser.CreateUserAttribute("userPassword", "1"); testLdapUser.CreateUserAttribute("description", "test"); if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["LDAPMatchFieldUsername"])) { if (ConfigurationManager.AppSettings["LDAPMatchFieldUsername"].Equals("cn")) LDAPMatchSearchField = new string[1] { testLdapUser.GetUserCn() }; else if (ConfigurationManager.AppSettings["LDAPMatchFieldUsername"].Equals("dn")) LDAPMatchSearchField = new string[1] { testLdapUser.GetUserDn() }; else if (ConfigurationManager.AppSettings["LDAPMatchFieldUsername"].Equals("sn")) LDAPMatchSearchField = new string[1] { testLdapUser.GetUserSn() }; else LDAPMatchSearchField = new string[1] { testLdapUser.GetUserAttribute( ConfigurationManager.AppSettings["LDAPMatchFieldUsername"] )[0] }; } //Set the test user return testLdapUser; }
public void InsertUserAttribute() { var user = new LdapUser(LdapUserDn, LdapUserCn, LdapUserSn, new Dictionary<string, List<string>> { {"description", new List<string> {"test description"}} }); const string addictionalDescription = "new test description Inserted"; user.InsertUserAttribute("description", addictionalDescription); Assert.IsTrue(user.GetUserAttribute("description").Contains(addictionalDescription)); user.InsertUserAttribute("description", null); user.InsertUserAttribute("description", ""); Assert.IsTrue(user.GetUserAttribute("description").Count == 2); }
public void CreateUserAttributeSingle() { var user = new LdapUser(LdapUserDn, LdapUserCn, LdapUserSn, LdapUserAttributes); const string newAttribute = "new test value 1"; user.CreateUserAttribute("newAttribute1", newAttribute); CollectionAssert.AreEqual(user.GetUserAttribute("newAttribute1"), new List<string> {newAttribute}); }
public void CreateUserAttributeList() { var user = new LdapUser(LdapUserDn, LdapUserCn, LdapUserSn, LdapUserAttributes); var newAttribute = new List<string> {"new test value 1", "new test value 2"}; user.CreateUserAttribute("newAttribute", newAttribute); CollectionAssert.AreEqual(user.GetUserAttribute("newAttribute"), newAttribute); }
public void OverwriteUserAttributeSingle() { var testUserCopy = new LdapUser(LdapUserDn, LdapUserCn, LdapUserSn, LdapUserAttributes); const string descriptions = "new test description 1"; const string telephoneNumbers = "123456789"; testUserCopy.OverwriteUserAttribute("description", descriptions); testUserCopy.OverwriteUserAttribute("telephoneNumber", telephoneNumbers); CollectionAssert.AreEqual(testUserCopy.GetUserAttribute("description"), new List<string> {descriptions}); CollectionAssert.AreEqual(testUserCopy.GetUserAttribute("telephoneNumber"), new List<string> {telephoneNumbers}); }
public void OverwriteUserAttributeList() { var testUserCopy = new LdapUser(LdapUserDn, LdapUserCn, LdapUserSn, LdapUserAttributes); var descriptions = new List<string> {"new test description 1", "new test description 2"}; var telephoneNumbers = new List<string> {"123456789", "987654321"}; testUserCopy.OverwriteUserAttribute("description", descriptions); testUserCopy.OverwriteUserAttribute("telephoneNumber", telephoneNumbers); CollectionAssert.AreEqual(testUserCopy.GetUserAttribute("description"), descriptions); CollectionAssert.AreEqual(testUserCopy.GetUserAttribute("telephoneNumber"), telephoneNumbers); }