use of com.zimbra.cs.account.Provisioning 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.Provisioning in project zm-mailbox by Zimbra.
the class AuthMechanism method newInstance.
public static AuthMechanism newInstance(Account acct, Map<String, Object> context) throws ServiceException {
String authMechStr = AuthMech.zimbra.name();
if (!acct.isIsExternalVirtualAccount()) {
Provisioning prov = Provisioning.getInstance();
Domain domain = prov.getDomain(acct);
// see if it specifies an alternate auth
if (domain != null) {
String am;
Boolean asAdmin = context == null ? null : (Boolean) context.get(AuthContext.AC_AS_ADMIN);
if (asAdmin != null && asAdmin) {
am = domain.getAuthMechAdmin();
if (am == null) {
// fallback to zimbraAuthMech if zimbraAuthMechAdmin is not specified
am = domain.getAuthMech();
}
} else {
am = domain.getAuthMech();
}
if (am != null) {
authMechStr = am;
}
}
}
if (authMechStr.startsWith(AuthMech.custom.name() + ":")) {
return new CustomAuth(AuthMech.custom, authMechStr);
} else {
try {
AuthMech authMech = AuthMech.fromString(authMechStr);
switch(authMech) {
case zimbra:
return new ZimbraAuth(authMech);
case ldap:
case ad:
return new LdapAuth(authMech);
case kerberos5:
return new Kerberos5Auth(authMech);
}
} catch (ServiceException e) {
ZimbraLog.account.warn("invalid auth mech", e);
}
ZimbraLog.account.warn("unknown value for " + Provisioning.A_zimbraAuthMech + ": " + authMechStr + ", falling back to default mech");
return new ZimbraAuth(AuthMech.zimbra);
}
}
use of com.zimbra.cs.account.Provisioning in project zm-mailbox by Zimbra.
the class FreeBusyProviderURLCheck method preModify.
/* (non-Javadoc)
* @see com.zimbra.cs.account.AttributeCallback#preModify(com.zimbra.cs.account.callback.CallbackContext, java.lang.String, java.lang.Object, java.util.Map, com.zimbra.cs.account.Entry)
*/
@Override
public void preModify(CallbackContext context, String attrName, Object attrValue, Map attrsToModify, Entry entry) throws ServiceException {
String value = (String) attrValue;
if (StringUtil.isNullOrEmpty(value)) {
// zimbraFreebusyExternalZimbraURL
return;
}
Provisioning prov = Provisioning.getInstance();
if (attrsToModify.containsKey(Provisioning.A_zimbraFreebusyExchangeURL) && (attrsToModify.containsKey(Provisioning.A_zimbraFreebusyExternalZimbraURL))) {
throw ServiceException.INVALID_REQUEST("Setting both " + Provisioning.A_zimbraFreebusyExchangeURL + " and " + Provisioning.A_zimbraFreebusyExternalZimbraURL + " is not allowed", null);
} else if (attrsToModify.containsKey(Provisioning.A_zimbraFreebusyExchangeURL)) {
String[] zimbraFbExtUrl = prov.getConfig().getFreebusyExternalZimbraURL();
if (zimbraFbExtUrl != null && zimbraFbExtUrl.length > 0) {
throw ServiceException.INVALID_REQUEST("Setting both " + Provisioning.A_zimbraFreebusyExchangeURL + " and " + Provisioning.A_zimbraFreebusyExternalZimbraURL + " is not allowed", null);
}
} else if (attrsToModify.containsKey(Provisioning.A_zimbraFreebusyExternalZimbraURL)) {
String exchngFbUrl = prov.getConfig().getFreebusyExchangeURL();
if (!StringUtil.isNullOrEmpty(exchngFbUrl)) {
throw ServiceException.INVALID_REQUEST("Setting both " + Provisioning.A_zimbraFreebusyExchangeURL + " and " + Provisioning.A_zimbraFreebusyExternalZimbraURL + " is not allowed", null);
}
}
}
use of com.zimbra.cs.account.Provisioning in project zm-mailbox by Zimbra.
the class AccountStatus method handleAccountStatusClosed.
private void handleAccountStatusClosed(Account account) throws ServiceException {
Provisioning prov = Provisioning.getInstance();
String status = account.getAccountStatus(prov);
if (status.equals(Provisioning.ACCOUNT_STATUS_CLOSED)) {
ZimbraLog.misc.info("removing account address and all its aliases from all distribution lists");
String[] addrToRemove = new String[] { account.getName() };
Set<String> dlIds = prov.getDistributionLists(account);
for (String dlId : dlIds) {
DistributionList dl = prov.get(Key.DistributionListBy.id, dlId);
if (dl != null) {
try {
// will remove all members that are aliases of the account too
prov.removeMembers(dl, addrToRemove);
} catch (ServiceException se) {
if (AccountServiceException.NO_SUCH_MEMBER.equals(se.getCode())) {
ZimbraLog.misc.debug("Member not found in dlist; skipping", se);
} else {
throw se;
}
}
}
}
}
}
use of com.zimbra.cs.account.Provisioning 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);
}
Aggregations