use of com.zimbra.cs.account.Account in project zm-mailbox by Zimbra.
the class LdapProvisioning method getIdentitiesByQuery.
private List<Identity> getIdentitiesByQuery(LdapEntry entry, ZLdapFilter filter, ZLdapContext initZlc) throws ServiceException {
List<Identity> result = new ArrayList<Identity>();
try {
String base = entry.getDN();
ZSearchResultEnumeration ne = helper.searchDir(base, filter, ZSearchControls.SEARCH_CTLS_SUBTREE(), initZlc, LdapServerType.REPLICA);
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
result.add(new LdapIdentity((Account) entry, sr.getDN(), sr.getAttributes(), this));
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to lookup identity via query: " + filter.toFilterString() + " message: " + e.getMessage(), e);
}
return result;
}
use of com.zimbra.cs.account.Account in project zm-mailbox by Zimbra.
the class LdapProvisioning method makeAccount.
private Account makeAccount(String dn, ZAttributes attrs, MakeObjectOpt makeObjOpt) throws ServiceException {
String userType = attrs.getAttrString(Provisioning.A_zimbraAccountCalendarUserType);
boolean isAccount = (userType == null) || userType.equals(AccountCalendarUserType.USER.toString());
String emailAddress = attrs.getAttrString(Provisioning.A_zimbraMailDeliveryAddress);
if (emailAddress == null)
emailAddress = mDIT.dnToEmail(dn, attrs);
Account acct = (isAccount) ? new LdapAccount(dn, emailAddress, attrs, null, this) : new LdapCalendarResource(dn, emailAddress, attrs, null, this);
setAccountDefaults(acct, makeObjOpt);
return acct;
}
use of com.zimbra.cs.account.Account in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAccountByForeignPrincipal.
private Account getAccountByForeignPrincipal(String foreignPrincipal, boolean loadFromMaster) throws ServiceException {
Account a = accountCache.getByForeignPrincipal(foreignPrincipal);
// bug 27966, always do a search so dup entries can be thrown
Account acct = getAccountByQuery(mDIT.mailBranchBaseDN(), filterFactory.accountByForeignPrincipal(foreignPrincipal), null, loadFromMaster);
// before bug 23372 was fixed.
if (a == null) {
a = acct;
accountCache.put(a);
}
return a;
}
use of com.zimbra.cs.account.Account in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAccountByForeignName.
@Override
public Account getAccountByForeignName(String foreignName, String application, Domain domain) throws ServiceException {
// first try direct match
Account acct = getAccountByForeignPrincipal(application + ":" + foreignName);
if (acct != null)
return acct;
if (domain == null) {
String[] parts = foreignName.split("@");
if (parts.length != 2)
return null;
String domainName = parts[1];
domain = getDomain(Key.DomainBy.foreignName, application + ":" + domainName, true);
}
if (domain == null)
return null;
// see if there is a custom hander on the domain
DomainNameMappingHandler.HandlerConfig handlerConfig = DomainNameMappingHandler.getHandlerConfig(domain, application);
String acctName;
if (handlerConfig != null) {
// invoke the custom handler
acctName = DomainNameMappingHandler.mapName(handlerConfig, foreignName, domain.getName());
} else {
// do our builtin mapping of {localpart}@{zimbra domain name}
acctName = foreignName.split("@")[0] + "@" + domain.getName();
}
return get(AccountBy.name, acctName);
}
use of com.zimbra.cs.account.Account in project zm-mailbox by Zimbra.
the class BUG_57866 method upgradeQuarantineAccount.
private void upgradeQuarantineAccount(ZLdapContext zlc) throws ServiceException {
String acctName = prov.getConfig().getAmavisQuarantineAccount();
if (acctName != null) {
printer.format("Checking quarantine account %s\n", acctName);
Account acct = prov.get(AccountBy.name, acctName);
setIsSystemAccount(zlc, acct);
}
}
Aggregations