use of com.zimbra.cs.account.ldap.entry.LdapAccount in project zm-mailbox by Zimbra.
the class LdapProvisioning method makeAccount.
private Account makeAccount(String dn, ZAttributes attrs, MakeObjectOpt makeObjOpt) throws ServiceException {
String userType = attrs.getAttrString(Provisioning.A_zimbraAccountCalendarUserType);
boolean isAccount = (userType == null) || userType.equals(AccountCalendarUserType.USER.toString());
String emailAddress = attrs.getAttrString(Provisioning.A_zimbraMailDeliveryAddress);
if (emailAddress == null)
emailAddress = mDIT.dnToEmail(dn, attrs);
Account acct = (isAccount) ? new LdapAccount(dn, emailAddress, attrs, null, this) : new LdapCalendarResource(dn, emailAddress, attrs, null, this);
setAccountDefaults(acct, makeObjOpt);
return acct;
}
use of com.zimbra.cs.account.ldap.entry.LdapAccount in project zm-mailbox by Zimbra.
the class TestContactGroup method returnMembersAsDlist.
@Test
public void returnMembersAsDlist() throws Exception {
Account account = Provisioning.getInstance().get(AccountBy.name, TestUtil.getAddress("user1"));
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account);
//TODO
OperationContext octxt = null;
Map<String, Object> fields = new HashMap<String, Object>();
fields.put(ContactConstants.A_fileAs, ContactConstants.FA_FIRST_LAST);
fields.put(ContactConstants.A_firstName, "test");
fields.put(ContactConstants.A_email, "test1@zimbra.com");
fields.put(ContactConstants.A_workEmail1, "test2@zimbra.com");
Contact contact = mbox.createContact(octxt, new ParsedContact(fields), Mailbox.ID_FOLDER_CONTACTS, null);
Account galMember = Provisioning.getInstance().get(AccountBy.name, TestUtil.getAddress("user2"));
LdapAccount ldapAccount = (LdapAccount) galMember;
String dn = ldapAccount.getDN();
String galEntryEmail = galMember.getName();
ContactGroup contactGroup = createContactGroup(new MemberData[] { new MemberData(Member.Type.CONTACT_REF, "" + contact.getId()), new MemberData(Member.Type.GAL_REF, dn), new MemberData(Member.Type.INLINE, "aaa@test.com"), new MemberData(Member.Type.INLINE, "zzz@test.com") });
contactGroup.derefAllMembers(mbox, octxt);
for (Member member : contactGroup.getDerefedMembers()) {
String memberKey = member.getDerefedKey();
System.out.println(memberKey);
}
String dlist = contactGroup.migrateToDlist(mbox, octxt);
// should be in member order
assertEquals("test1@zimbra.com, test2@zimbra.com, " + galEntryEmail + ", aaa@test.com, zzz@test.com", dlist);
}
use of com.zimbra.cs.account.ldap.entry.LdapAccount in project zm-mailbox by Zimbra.
the class TestLdapProvDynamicGroup method memberAttrViaSlapdOverlay.
/*
* Test member attr, which is populated by OpenLDAP dyngroup overlay
*/
@Test
public void memberAttrViaSlapdOverlay() throws Exception {
SKIP_FOR_INMEM_LDAP_SERVER(SkipTestReason.DYNAMIC_GROUP_OVERLAY);
Group group = createDynamicGroup(genGroupNameLocalPart());
Account acct1 = provUtil.createAccount(genAcctNameLocalPart("1"), domain);
Account acct2 = provUtil.createAccount(genAcctNameLocalPart("2"), domain);
prov.addGroupMembers(group, new String[] { acct1.getName(), acct2.getName() });
group = prov.getGroup(DistributionListBy.id, group.getId());
String[] memberDNs = group.getMultiAttr(Provisioning.A_member);
Set<String> expected = Sets.newHashSet(((LdapAccount) acct1).getDN(), ((LdapAccount) acct2).getDN(), // LdapProvisioning.DYNAMIC_GROUP_STATIC_UNIT_NAME
"cn=external," + ((LdapDynamicGroup) group).getDN());
Verify.verifyEquals(expected, memberDNs);
}
use of com.zimbra.cs.account.ldap.entry.LdapAccount in project zm-mailbox by Zimbra.
the class TestContactGroup method derefGal.
@Test
public void derefGal() throws Exception {
Account account = Provisioning.getInstance().get(AccountBy.name, TestUtil.getAddress("user1"));
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account);
//TODO
OperationContext octxt = null;
Account galMember = Provisioning.getInstance().get(AccountBy.name, TestUtil.getAddress("user2"));
LdapAccount ldapAccount = (LdapAccount) galMember;
String dn = ldapAccount.getDN();
String email = galMember.getName();
ContactGroup contactGroup = createContactGroup(new MemberData[] { new MemberData(Member.Type.GAL_REF, dn), new MemberData(Member.Type.INLINE, "aaa@test.com"), new MemberData(Member.Type.INLINE, "zzz@test.com") });
contactGroup.derefAllMembers(mbox, octxt);
boolean gotGalRefMember = false;
String prevMemberKey = null;
for (Member member : contactGroup.getDerefedMembers()) {
String memberKey = member.getDerefedKey();
if (prevMemberKey != null) {
assertTrue(prevMemberKey.compareTo(memberKey) < 0);
}
prevMemberKey = memberKey;
Member.Type type = member.getType();
if (type == Member.Type.GAL_REF) {
assertEquals(email, memberKey);
gotGalRefMember = true;
}
// System.out.println(memberKey);
}
List<String> emailAddrs = contactGroup.getEmailAddresses(false, mbox, octxt, false);
assertEquals(3, emailAddrs.size());
assertTrue(emailAddrs.contains(email));
assertTrue(emailAddrs.contains("aaa@test.com"));
assertTrue(emailAddrs.contains("zzz@test.com"));
assertTrue(gotGalRefMember);
}
Aggregations