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