public static void RunTests(Credentials cred) { System.Console.WriteLine("Running add tests ..."); myDN = cred.myDN; hostName = cred.hostName; upn = cred.upn; password = cred.password; portNumber = cred.portNumber; //False credentials myDN_F = cred.myDN_F; hostName_F = cred.hostName_F; upn_F = cred.upn_F; password_F = cred.password_F; portNumber_F = cred.portNumber_F; ILdapConnection ldapConnection = LdapConnection.LdapInit(hostName, portNumber); ldapConnection.LdapSimpleBindS(myDN, password); LdapUser user = LdapUser.CreateRandomUser(ldapConnection); ILdapConnection ldapConnectionSASL = LdapConnection.LdapInit(hostName, portNumber); ldapConnectionSASL.VmDirSafeLDAPBind(hostName, upn, password); string UserName = Guid.NewGuid().ToString("N"); string UserNameSASL = Guid.NewGuid().ToString("N"); Ldap_Add_Object_Success(ldapConnection, UserName); Ldap_Add_Object_SASL_Success(ldapConnectionSASL, UserNameSASL); Ldap_Add_Object_Failure(ldapConnection, UserName); Ldap_Add_Object_SASL_Failure(ldapConnectionSASL, UserNameSASL); }
public static void RunTests(Credentials cred) { System.Console.WriteLine("Running modify tests ..."); myDN = cred.myDN; hostName = cred.hostName; upn = cred.upn; password = cred.password; portNumber = cred.portNumber; //False credentials myDN_F = cred.myDN_F; hostName_F = cred.hostName_F; upn_F = cred.upn_F; password_F = cred.password_F; portNumber_F = cred.portNumber_F; ldapConnection = LdapConnection.LdapInit(hostName, portNumber); Assert.IsNotNull(ldapConnection); ldapConnection.LdapSimpleBindS(myDN, password); LdapUser user = LdapUser.CreateRandomUser(ldapConnection); LdapModify_AddAttribute_Success(ldapConnection, user); LdapModify_AddAttribute_Failure(ldapConnection, user); LdapModify_ReplaceAttribute_Success(ldapConnection, user); LdapModify_DeleteAttribute_Success(ldapConnection, user); }
public static void Ldap_Delete_SASL_Success() { ILdapConnection ldapConnection = LdapConnection.LdapInit(hostName, portNumber); ldapConnection.VmDirSafeLDAPBind(hostName, upn, password); LdapUser user = LdapUser.CreateRandomUser(ldapConnection); try { ldapConnection.DeleteObject(user.DN); } catch { Assert.Fail(); } }
public static void Ldap_Delete_Success() { ILdapConnection ldapConnection = LdapConnection.LdapInit(hostName, portNumber); ldapConnection.LdapSimpleBindS(myDN, password); LdapUser user = LdapUser.CreateRandomUser(ldapConnection); try { ldapConnection.DeleteObject(user.DN); } catch { Assert.Fail(); } }
public static void LdapModify_ReplaceAttribute_Success(ILdapConnection ldapConnection, LdapUser user) { LdapMod[] lMods = new LdapMod[1]; lMods[0] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_REPLACE, "sn", new string[] { "Barry" }); try { ldapConnection.ModifyObject(user.DN, lMods); } catch { Assert.Fail(); } }
public static void LdapModify_AddAttribute_Failure(ILdapConnection ldapConnection, LdapUser user) { LdapMod[] lMods = new LdapMod[1]; lMods[0] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, "cn", new string[] { "Allen" }); try { ldapConnection.ModifyObject(user.DN, lMods); Assert.Fail(); } catch { //Expected Exception } }