use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class SendShareNotification method getGrantee.
/**
* returns the grantee entry and displayName if there is one
*
* @param zsc
* @param granteeType
* @param granteeId
* @param granteeName
* @return
* @throws ServiceException
*/
private Pair<NamedEntry, String> getGrantee(ZimbraSoapContext zsc, byte granteeType, String granteeId, String granteeName) throws ServiceException {
NamedEntry entryById = null;
NamedEntry entryByName = null;
if (granteeId != null) {
entryById = FolderAction.lookupGranteeByZimbraId(granteeId, granteeType);
if (entryById == null)
throw MailServiceException.NO_SUCH_GRANTEE(granteeId, null);
}
if (granteeName != null) {
try {
entryByName = FolderAction.lookupGranteeByName(granteeName, granteeType, zsc);
} catch (ServiceException se) {
throw MailServiceException.NO_SUCH_GRANTEE(granteeName, null);
}
}
if (entryById == null && entryByName == null) {
throw MailServiceException.NO_SUCH_GRANTEE("", null);
}
if (entryById != null && entryByName != null && !entryById.getId().equals(entryByName.getId())) {
throw ServiceException.INVALID_REQUEST("grantee name does not match grantee id", null);
}
NamedEntry grantee = (entryById != null) ? entryById : entryByName;
String displayName;
if (grantee instanceof Account) {
displayName = ((Account) grantee).getDisplayName();
} else if (grantee instanceof Group) {
displayName = ((Group) grantee).getDisplayName();
} else {
throw ServiceException.INVALID_REQUEST("unsupported grantee type for sending share notification email", null);
}
return new Pair<NamedEntry, String>(grantee, displayName);
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class TestGroups method createDynamicGroup.
public static Group createDynamicGroup(String name) throws Exception {
Provisioning prov = Provisioning.getInstance();
Group group = prov.getGroup(Key.DistributionListBy.name, name, true);
if (group != null) {
ZimbraLog.test.warn("createDynamicGroup(%s) - already existed!!!", name);
return group;
}
Map<String, Object> attrs = Maps.newHashMap();
group = prov.createGroup(name, attrs, true);
if (group == null) {
ZimbraLog.test.warn("createDynamicGroup returning null for '%s'", name);
}
return group;
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class TestLdapHelper method hasSubordinates.
@Test
public void hasSubordinates() throws Exception {
Domain domain = provUtil.createDomain(genDomainName(baseDomainName()));
Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
Group group = provUtil.createGroup(genGroupNameLocalPart(), domain, true);
String domainDn = ((LdapDomain) domain).getDN();
String acctBaseDn = prov.getDIT().domainDNToAccountBaseDN(domainDn);
String dynGroupsBaseDn = prov.getDIT().domainDNToDynamicGroupsBaseDN(domainDn);
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.UNITTEST);
// verify dn has Subordinates
assertTrue(hasSubordinates(zlc, acctBaseDn));
assertTrue(hasSubordinates(zlc, dynGroupsBaseDn));
provUtil.deleteAccount(acct);
provUtil.deleteGroup(group);
// verify dn don't have Subordinates
assertFalse(hasSubordinates(zlc, acctBaseDn));
assertFalse(hasSubordinates(zlc, dynGroupsBaseDn));
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class TestLdapProvCountObjects method countDL.
@Test
public void countDL() throws Exception {
Group staticGroup = provUtil.createGroup(genGroupNameLocalPart("static"), domain, false);
Group dynamicGroup = provUtil.createGroup(genGroupNameLocalPart("dynamic"), domain, true);
Domain subDomain = provUtil.createDomain(genDomainName(domain.getName()));
Group staticGroup1Sub = provUtil.createGroup(genGroupNameLocalPart("static-1"), subDomain, false);
Group dynamicGroup1Sub = provUtil.createGroup(genGroupNameLocalPart("dynamic-1"), subDomain, true);
Group staticGroup2Sub = provUtil.createGroup(genGroupNameLocalPart("static-2"), subDomain, false);
Group dynamicGroup2Sub = provUtil.createGroup(genGroupNameLocalPart("dynamic-2"), subDomain, true);
long num;
num = prov.countObjects(CountObjectsType.dl, domain, null);
// groups in sub domains should not be counted
assertEquals(2, num);
provUtil.deleteGroup(staticGroup);
provUtil.deleteGroup(dynamicGroup);
provUtil.deleteGroup(staticGroup1Sub);
provUtil.deleteGroup(dynamicGroup1Sub);
provUtil.deleteGroup(staticGroup2Sub);
provUtil.deleteGroup(dynamicGroup2Sub);
provUtil.deleteDomain(subDomain);
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class TestSearchGalGroups method searchGroup.
@Test
public void searchGroup() throws Exception {
SKIP_FOR_INMEM_LDAP_SERVER(SkipTestReason.DN_SUBTREE_MATCH_FILTER);
Map<String, Object> attrs = Maps.newHashMap();
attrs.put(Provisioning.A_zimbraDistributionListSubscriptionPolicy, ZAttrProvisioning.DistributionListSubscriptionPolicy.ACCEPT.name());
Group group = provUtil.createGroup(genGroupNameLocalPart(), domain, attrs, false);
Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
// make acct owner of the the group
String right = Group.GroupOwner.GROUP_OWNER_RIGHT.getName();
prov.grantRight(TargetType.dl.getCode(), TargetBy.name, group.getName(), GranteeType.GT_USER.getCode(), GranteeBy.name, acct.getName(), null, right, null);
// make acct member of the group
prov.addGroupMembers(group, new String[] { acct.getName() });
// test with GSA on
GalTestUtil.enableGalSyncAccount(prov, domain.getName());
testSearchGroup(acct, group, Boolean.TRUE, MemberOfSelector.all, true, true);
testSearchGroup(acct, group, Boolean.TRUE, null, true, true);
testSearchGroup(acct, group, null, MemberOfSelector.all, true, true);
testSearchGroup(acct, group, null, null, true, true);
// test with GSA off
GalTestUtil.disableGalSyncAccount(prov, domain.getName());
testSearchGroup(acct, group, Boolean.TRUE, MemberOfSelector.all, true, true);
testSearchGroup(acct, group, Boolean.TRUE, null, true, true);
testSearchGroup(acct, group, null, MemberOfSelector.all, true, true);
testSearchGroup(acct, group, null, null, true, true);
provUtil.deleteGroup(group);
provUtil.deleteAccount(acct);
}
Aggregations