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);
}
}
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);
}
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);
}
}
}
}
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);
}
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);
}
}
}
Aggregations