Search in sources :

Example 96 with Group

use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.

the class LdapProvisioning method createDelegatedGroup.

@Override
public Group createDelegatedGroup(String name, Map<String, Object> attrs, boolean dynamic, Account creator) throws ServiceException {
    if (creator == null) {
        throw ServiceException.INVALID_REQUEST("must have a creator account", null);
    }
    Group group = dynamic ? createDynamicGroup(name, attrs, creator) : createDistributionList(name, attrs, creator);
    grantRight(TargetType.dl.getCode(), TargetBy.id, group.getId(), GranteeType.GT_USER.getCode(), GranteeBy.id, creator.getId(), null, Group.GroupOwner.GROUP_OWNER_RIGHT.getName(), null);
    return group;
}
Also used : Group(com.zimbra.cs.account.Group) DynamicGroup(com.zimbra.cs.account.DynamicGroup) LdapDynamicGroup(com.zimbra.cs.account.ldap.entry.LdapDynamicGroup)

Example 97 with Group

use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.

the class AddDistributionListAlias method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    AddDistributionListAliasRequest req = JaxbUtil.elementToJaxb(request);
    String alias = req.getAlias();
    Group group = getGroupFromContext(context);
    String id = req.getId();
    defendAgainstGroupHarvesting(group, DistributionListBy.id, id, zsc, Admin.R_addGroupAlias, Admin.R_addDistributionListAlias);
    // if the admin can create an alias in the domain
    checkDomainRightByEmail(zsc, alias, Admin.R_createAlias);
    prov.addGroupAlias(group, alias);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "AddDistributionListAlias", "name", group.getName(), "alias", alias }));
    return zsc.jaxbToElement(new AddDistributionListAliasResponse());
}
Also used : Group(com.zimbra.cs.account.Group) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) AddDistributionListAliasRequest(com.zimbra.soap.admin.message.AddDistributionListAliasRequest) AddDistributionListAliasResponse(com.zimbra.soap.admin.message.AddDistributionListAliasResponse) Provisioning(com.zimbra.cs.account.Provisioning)

Example 98 with Group

use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.

the class AddDistributionListMember method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    OperationContext octxt = getOperationContext(zsc, context);
    Provisioning prov = Provisioning.getInstance();
    Group group = getGroupFromContext(context);
    String id = request.getAttribute(AdminConstants.E_ID);
    defendAgainstGroupHarvesting(group, DistributionListBy.id, id, zsc, Admin.R_addGroupMember, Admin.R_addDistributionListMember);
    List<String> memberList = getMemberList(request, context);
    if (memberList.isEmpty()) {
        throw ServiceException.INVALID_REQUEST("members to add not specified", null);
    }
    String[] members = memberList.toArray(new String[0]);
    prov.addGroupMembers(group, members);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "AddDistributionListMember", "name", group.getName(), "members", Arrays.deepToString(members) }));
    // send share notification email
    if (group.isDynamic()) {
    // do nothing for now
    } else {
        boolean sendShareInfoMsg = group.getBooleanAttr(Provisioning.A_zimbraDistributionListSendShareMessageToNewMembers, true);
        if (sendShareInfoMsg) {
            ShareInfo.NotificationSender.sendShareInfoMessage(octxt, (DistributionList) group, members);
        }
    }
    return zsc.jaxbToElement(new AddDistributionListMemberResponse());
}
Also used : OperationContext(com.zimbra.cs.mailbox.OperationContext) Group(com.zimbra.cs.account.Group) AddDistributionListMemberResponse(com.zimbra.soap.admin.message.AddDistributionListMemberResponse) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Provisioning(com.zimbra.cs.account.Provisioning)

Example 99 with Group

use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.

the class ModifyDistributionList method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    ModifyDistributionListRequest req = JaxbUtil.elementToJaxb(request);
    String id = req.getId();
    Group group = getGroupFromContext(context);
    Map<String, Object> attrs = req.getAttrsAsOldMultimap();
    defendAgainstGroupHarvesting(group, DistributionListBy.id, id, zsc, attrs, attrs);
    // pass in true to checkImmutable
    prov.modifyAttrs(group, attrs, true);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "ModifyDistributionList", "name", group.getName() }, attrs));
    Element response = zsc.createElement(AdminConstants.MODIFY_DISTRIBUTION_LIST_RESPONSE);
    GetDistributionList.encodeDistributionList(response, group);
    return response;
}
Also used : Group(com.zimbra.cs.account.Group) ModifyDistributionListRequest(com.zimbra.soap.admin.message.ModifyDistributionListRequest) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Example 100 with Group

use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.

the class TestLdapProvDynamicGroup method removeMembersBasic.

/*
     * Test remove members
     */
@Test
public void removeMembersBasic() throws Exception {
    Group group = createDynamicGroup(genGroupNameLocalPart());
    Account acct1 = provUtil.createAccount(genAcctNameLocalPart("1"), domain);
    Account acct2 = provUtil.createAccount(genAcctNameLocalPart("2"), domain);
    String extAddr1 = "user1@external.com";
    String extAddr2 = "user2@external.com";
    prov.addGroupMembers(group, new String[] { acct1.getName(), acct2.getName(), extAddr1, extAddr2 });
    String[] members = prov.getGroupMembers(group);
    Set<String> expected = Sets.newHashSet(acct1.getName(), acct2.getName(), extAddr1, extAddr2);
    Verify.verifyEquals(expected, members);
    prov.removeGroupMembers(group, new String[] { acct1.getName(), extAddr1 });
    members = prov.getGroupMembers(group);
    expected = Sets.newHashSet(acct2.getName(), extAddr2);
    Verify.verifyEquals(expected, members);
    // remove non-existing members, should not throw any exception
    prov.removeGroupMembers(group, new String[] { group.getName() });
    prov.removeGroupMembers(group, new String[] { "bogus" });
}
Also used : DynamicGroup(com.zimbra.cs.account.DynamicGroup) Group(com.zimbra.cs.account.Group) LdapDynamicGroup(com.zimbra.cs.account.ldap.entry.LdapDynamicGroup) LdapAccount(com.zimbra.cs.account.ldap.entry.LdapAccount) GuestAccount(com.zimbra.cs.account.GuestAccount) Account(com.zimbra.cs.account.Account) Test(org.junit.Test)

Aggregations

Group (com.zimbra.cs.account.Group)110 Account (com.zimbra.cs.account.Account)53 Test (org.junit.Test)42 DynamicGroup (com.zimbra.cs.account.DynamicGroup)27 ServiceException (com.zimbra.common.service.ServiceException)23 SoapTransport (com.zimbra.common.soap.SoapTransport)23 Provisioning (com.zimbra.cs.account.Provisioning)23 LdapDynamicGroup (com.zimbra.cs.account.ldap.entry.LdapDynamicGroup)21 Domain (com.zimbra.cs.account.Domain)17 GuestAccount (com.zimbra.cs.account.GuestAccount)17 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)17 Element (com.zimbra.common.soap.Element)16 AccountServiceException (com.zimbra.cs.account.AccountServiceException)15 NamedEntry (com.zimbra.cs.account.NamedEntry)14 LdapAccount (com.zimbra.cs.account.ldap.entry.LdapAccount)12 DistributionListActionRequest (com.zimbra.soap.account.message.DistributionListActionRequest)12 DistributionListAction (com.zimbra.soap.account.type.DistributionListAction)12 DistributionListActionResponse (com.zimbra.soap.account.message.DistributionListActionResponse)11 DistributionList (com.zimbra.cs.account.DistributionList)9 Entry (com.zimbra.cs.account.Entry)9