Search in sources :

Example 6 with LdapProv

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

the class ProvUtil method doGetAllAccounts.

private void doGetAllAccounts(String[] args) throws ServiceException {
    LdapProv ldapProv = (LdapProv) prov;
    boolean verbose = false;
    boolean applyDefault = true;
    String d = null;
    String s = null;
    int i = 1;
    while (i < args.length) {
        String arg = args[i];
        if (arg.equals("-v")) {
            verbose = true;
        } else if (arg.equals("-e")) {
            applyDefault = false;
        } else if (arg.equals("-s")) {
            i++;
            if (i < args.length) {
                if (s == null) {
                    s = args[i];
                } else {
                    console.println("invalid arg: " + args[i] + ", already specified -s with " + s);
                    usage();
                    return;
                }
            } else {
                usage();
                return;
            }
        } else {
            if (d == null) {
                d = arg;
            } else {
                console.println("invalid arg: " + arg + ", already specified domain: " + d);
                usage();
                return;
            }
        }
        i++;
    }
    if (!applyDefault && !verbose) {
        console.println(ERR_INVALID_ARG_EV);
        usage();
        return;
    }
    Server server = null;
    if (s != null) {
        server = lookupServer(s);
    }
    if (d == null) {
        doGetAllAccounts(ldapProv, null, server, verbose, applyDefault, null);
    } else {
        Domain domain = lookupDomain(d, ldapProv);
        doGetAllAccounts(ldapProv, domain, server, verbose, applyDefault, null);
    }
}
Also used : LdapProv(com.zimbra.cs.account.ldap.LdapProv)

Example 7 with LdapProv

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

the class ProvUtil method doGetEffectiveRights.

private void doGetEffectiveRights(String[] args) throws ServiceException, ArgException {
    RightArgs ra = new RightArgs(args);
    getRightArgsTarget(ra);
    if (prov instanceof LdapProv) {
        // must provide grantee info
        getRightArgsGrantee(ra, false, false);
    } else {
        // has more args, use it for the requested grantee
        if (ra.mCurPos < args.length) {
            getRightArgsGrantee(ra, false, 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]);
        }
    }
    TargetBy targetBy = (ra.mTargetIdOrName == null) ? null : guessTargetBy(ra.mTargetIdOrName);
    GranteeBy granteeBy = (ra.mGranteeIdOrName == null) ? null : guessGranteeBy(ra.mGranteeIdOrName);
    RightCommand.EffectiveRights effRights = prov.getEffectiveRights(ra.mTargetType, targetBy, ra.mTargetIdOrName, granteeBy, ra.mGranteeIdOrName, expandSetAttrs, expandGetAttrs);
    console.println("Account " + effRights.granteeName() + " has the following rights on target " + effRights.targetType() + " " + effRights.targetName());
    dumpEffectiveRight(effRights, expandSetAttrs, expandGetAttrs);
}
Also used : GranteeBy(com.zimbra.soap.admin.type.GranteeSelector.GranteeBy) TargetBy(com.zimbra.soap.type.TargetBy) RightCommand(com.zimbra.cs.account.accesscontrol.RightCommand) LdapProv(com.zimbra.cs.account.ldap.LdapProv)

Example 8 with LdapProv

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

the class DataSourceCallback method scheduleCos.

/**
     * Updates data source schedules for all accounts that are on the current server
     * and in the given COS.
     */
private void scheduleCos(Cos cos) throws ServiceException {
    ZimbraLog.datasource.info("Updating schedule for all DataSources for all accounts in COS %s.", cos.getName());
    List<Account> accts;
    Provisioning prov = Provisioning.getInstance();
    // Look up all account id's for this server
    if (prov instanceof LdapProv)
        accts = lookupAccountsFromLDAP(prov, cos.getId());
    else
        accts = lookupAccountsFromDB(prov);
    // Update schedules for all data sources on this server
    for (Account account : accts) {
        if (account != null && Provisioning.ACCOUNT_STATUS_ACTIVE.equals(account.getAccountStatus(prov))) {
            Cos accountCos = prov.getCOS(account);
            if (accountCos != null && cos.getId().equals(accountCos.getId())) {
                scheduleAccount(account);
            }
        }
    }
}
Also used : Account(com.zimbra.cs.account.Account) Cos(com.zimbra.cs.account.Cos) Provisioning(com.zimbra.cs.account.Provisioning) LdapProv(com.zimbra.cs.account.ldap.LdapProv)

Example 9 with LdapProv

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

the class AdminGroup method postModify.

@Override
public void postModify(CallbackContext context, String attrName, Entry entry) {
    if (!(entry instanceof DistributionList))
        return;
    Provisioning prov = Provisioning.getInstance();
    if (!(prov instanceof LdapProv))
        return;
    DistributionList group = (DistributionList) entry;
    ((LdapProv) prov).removeFromCache(group);
}
Also used : Provisioning(com.zimbra.cs.account.Provisioning) LdapProv(com.zimbra.cs.account.ldap.LdapProv) DistributionList(com.zimbra.cs.account.DistributionList)

Example 10 with LdapProv

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

the class DisplayName method preModify.

@Override
public void preModify(CallbackContext context, String attrName, Object value, Map attrsToModify, Entry entry) throws ServiceException {
    if (!((entry instanceof Account) || (entry instanceof DistributionList)))
        return;
    String displayName;
    // update cn only if we are not unsetting display name(cn is required for ZIMBRA_DEFAULT_PERSON_OC)
    SingleValueMod mod = singleValueMod(attrName, value);
    if (mod.unsetting())
        return;
    else
        displayName = mod.value();
    String namingRdnAttr = null;
    Provisioning prov = Provisioning.getInstance();
    if (prov instanceof LdapProv) {
        namingRdnAttr = ((LdapProv) prov).getDIT().getNamingRdnAttr(entry);
    }
    // update cn only if it is not the naming attr
    if (// non LdapProvisioning, pass thru
    namingRdnAttr == null || !namingRdnAttr.equals(Provisioning.A_cn)) {
        if (!attrsToModify.containsKey(Provisioning.A_cn)) {
            attrsToModify.put(Provisioning.A_cn, displayName);
        }
    }
}
Also used : Account(com.zimbra.cs.account.Account) Provisioning(com.zimbra.cs.account.Provisioning) LdapProv(com.zimbra.cs.account.ldap.LdapProv) DistributionList(com.zimbra.cs.account.DistributionList)

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