Search in sources :

Example 1 with LdapProv

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

the class ProvUtil method doRenameDomain.

private void doRenameDomain(String[] args) throws ServiceException {
    // Note: after rename domain, the zmprov instance will stay in "master only" mode.
    if (!useLdapMaster) {
        ((LdapProv) prov).alwaysUseMaster();
    }
    LdapProv lp = (LdapProv) prov;
    Domain domain = lookupDomain(args[1]);
    lp.renameDomain(domain.getId(), args[2]);
    printOutput("domain " + args[1] + " renamed to " + args[2]);
    printOutput("Note: use zmlocalconfig to check and update any localconfig settings referencing domain '" + args[1] + "' on all servers.");
    printOutput("Use /opt/zimbra/libexec/zmdkimkeyutil to recreate the DKIM entries for new domain name if required.");
}
Also used : LdapProv(com.zimbra.cs.account.ldap.LdapProv)

Example 2 with LdapProv

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

the class ProvUtil method doSyncGal.

private void doSyncGal(String[] args) throws ServiceException {
    String domain = args[1];
    String token = args.length == 3 ? args[2] : "";
    Domain d = lookupDomain(domain);
    SearchGalResult result = null;
    if (prov instanceof LdapProv) {
        GalContact.Visitor visitor = new GalContact.Visitor() {

            @Override
            public void visit(GalContact gc) throws ServiceException {
                dumpContact(gc);
            }
        };
        result = prov.syncGal(d, token, visitor);
    } else {
        result = ((SoapProvisioning) prov).searchGal(d, "", GalSearchType.all, token, 0, 0, null);
        for (GalContact contact : result.getMatches()) {
            dumpContact(contact);
        }
    }
    if (result.getToken() != null) {
        console.println("\n# token = " + result.getToken() + "\n");
    }
}
Also used : PublishedShareInfoVisitor(com.zimbra.cs.account.Provisioning.PublishedShareInfoVisitor) SearchGalResult(com.zimbra.cs.account.Provisioning.SearchGalResult) LdapProv(com.zimbra.cs.account.ldap.LdapProv)

Example 3 with LdapProv

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

the class ProvUtil method doSearchGal.

private void doSearchGal(String[] args) throws ServiceException, ArgException {
    if (args.length < 3) {
        usage();
        return;
    }
    String domain = args[1];
    String query = args[2];
    Map<String, Object> attrs = getMap(args, 3);
    String limitStr = (String) attrs.get("limit");
    int limit = limitStr == null ? 0 : Integer.parseInt(limitStr);
    String offsetStr = (String) attrs.get("offset");
    int offset = offsetStr == null ? 0 : Integer.parseInt(offsetStr);
    String sortBy = (String) attrs.get("sortBy");
    Domain d = lookupDomain(domain);
    SearchGalResult result;
    if (prov instanceof LdapProv) {
        if (offsetStr != null) {
            throw ServiceException.INVALID_REQUEST("offset is not supported with -l", null);
        }
        if (sortBy != null) {
            throw ServiceException.INVALID_REQUEST("sortBy is not supported with -l", null);
        }
        GalContact.Visitor visitor = new GalContact.Visitor() {

            @Override
            public void visit(GalContact gc) throws ServiceException {
                dumpContact(gc);
            }
        };
        result = prov.searchGal(d, query, GalSearchType.all, limit, visitor);
    } else {
        result = ((SoapProvisioning) prov).searchGal(d, query, GalSearchType.all, null, limit, offset, sortBy);
        for (GalContact contact : result.getMatches()) {
            dumpContact(contact);
        }
    }
}
Also used : PublishedShareInfoVisitor(com.zimbra.cs.account.Provisioning.PublishedShareInfoVisitor) SearchGalResult(com.zimbra.cs.account.Provisioning.SearchGalResult) LdapProv(com.zimbra.cs.account.ldap.LdapProv)

Example 4 with LdapProv

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

the class ProvUtil method doGetAllEffectiveRights.

private void doGetAllEffectiveRights(String[] args) throws ServiceException, ArgException {
    RightArgs ra = new RightArgs(args);
    if (prov instanceof LdapProv) {
        // must provide grantee info
        getRightArgsGrantee(ra, true, false);
    } else {
        // has more args, use it for the requested grantee
        if (ra.mCurPos < args.length) {
            getRightArgsGrantee(ra, true, false);
        }
    }
    boolean expandSetAttrs = false;
    boolean expandGetAttrs = false;
    // if there are more args, see if they are expandSetAttrs/expandGetAttrs
    for (int i = ra.mCurPos; i < args.length; i++) {
        if ("expandSetAttrs".equals(args[i])) {
            expandSetAttrs = true;
        } else if ("expandGetAttrs".equals(args[i])) {
            expandGetAttrs = true;
        } else {
            throw new ArgException("unrecognized arg: " + args[i]);
        }
    }
    GranteeBy granteeBy = (ra.mGranteeIdOrName == null) ? null : guessGranteeBy(ra.mGranteeIdOrName);
    RightCommand.AllEffectiveRights allEffRights = prov.getAllEffectiveRights(ra.mGranteeType, granteeBy, ra.mGranteeIdOrName, expandSetAttrs, expandGetAttrs);
    console.println(allEffRights.granteeType() + " " + allEffRights.granteeName() + "(" + allEffRights.granteeId() + ")" + " has the following rights:");
    for (Map.Entry<TargetType, RightCommand.RightsByTargetType> rightsByTargetType : allEffRights.rightsByTargetType().entrySet()) {
        RightCommand.RightsByTargetType rbtt = rightsByTargetType.getValue();
        if (!rbtt.hasNoRight()) {
            dumpRightsByTargetType(rightsByTargetType.getKey(), rbtt, expandSetAttrs, expandGetAttrs);
        }
    }
}
Also used : LdapProv(com.zimbra.cs.account.ldap.LdapProv) GranteeBy(com.zimbra.soap.admin.type.GranteeSelector.GranteeBy) TargetType(com.zimbra.cs.account.accesscontrol.TargetType) RightCommand(com.zimbra.cs.account.accesscontrol.RightCommand) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap)

Example 5 with LdapProv

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

the class ProvUtil method doGetCreateObjectAttrs.

/**
     * for testing only, not used in production
     */
private void doGetCreateObjectAttrs(String[] args) throws ServiceException {
    String targetType = args[1];
    Key.DomainBy domainBy = null;
    String domain = null;
    if (!args[2].equals("null")) {
        domainBy = guessDomainBy(args[2]);
        domain = args[2];
    }
    Key.CosBy cosBy = null;
    String cos = null;
    if (!args[3].equals("null")) {
        cosBy = guessCosBy(args[3]);
        cos = args[3];
    }
    GranteeBy granteeBy = null;
    String grantee = null;
    // for SoapProvisioning, -a {admin account} -p {password} is required with zmprov
    if (prov instanceof LdapProv) {
        granteeBy = guessGranteeBy(args[4]);
        grantee = args[4];
    }
    console.println("Domain:  " + domain);
    console.println("Cos:     " + cos);
    console.println("Grantee: " + grantee);
    console.println();
    RightCommand.EffectiveRights effRights = prov.getCreateObjectAttrs(targetType, domainBy, domain, cosBy, cos, granteeBy, grantee);
    displayAttrs("set", true, effRights.canSetAllAttrs(), effRights.canSetAttrs());
}
Also used : GranteeBy(com.zimbra.soap.admin.type.GranteeSelector.GranteeBy) RightCommand(com.zimbra.cs.account.accesscontrol.RightCommand) Key(com.zimbra.common.account.Key) LdapProv(com.zimbra.cs.account.ldap.LdapProv)

Aggregations

LdapProv (com.zimbra.cs.account.ldap.LdapProv)38 Domain (com.zimbra.cs.account.Domain)14 Account (com.zimbra.cs.account.Account)12 HashMap (java.util.HashMap)12 DistributionList (com.zimbra.cs.account.DistributionList)8 Provisioning (com.zimbra.cs.account.Provisioning)8 ServiceException (com.zimbra.common.service.ServiceException)7 NamedEntry (com.zimbra.cs.account.NamedEntry)6 LdapEntry (com.zimbra.cs.account.ldap.entry.LdapEntry)6 HashSet (java.util.HashSet)6 Map (java.util.Map)5 AccountServiceException (com.zimbra.cs.account.AccountServiceException)4 LdapDIT (com.zimbra.cs.account.ldap.LdapDIT)4 List (java.util.List)4 Entry (com.zimbra.cs.account.Entry)3 CacheEntry (com.zimbra.cs.account.Provisioning.CacheEntry)3 RightCommand (com.zimbra.cs.account.accesscontrol.RightCommand)3 ZLdapContext (com.zimbra.cs.ldap.ZLdapContext)3 GranteeBy (com.zimbra.soap.admin.type.GranteeSelector.GranteeBy)3 PublishedShareInfoVisitor (com.zimbra.cs.account.Provisioning.PublishedShareInfoVisitor)2