use of com.zimbra.cs.ldap.ZLdapSchema in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAttrsInOCs.
@Override
public void getAttrsInOCs(String[] ocs, Set<String> attrsInOCs) throws ServiceException {
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.GET_SCHEMA);
ZLdapSchema schema = zlc.getSchema();
for (String oc : ocs) {
try {
ZLdapSchema.ZObjectClassDefinition ocSchema = schema.getObjectClass(oc);
if (ocSchema != null) {
List<String> optAttrs = ocSchema.getOptionalAttributes();
for (String attr : optAttrs) {
attrsInOCs.add(attr);
}
List<String> reqAttrs = ocSchema.getRequiredAttributes();
for (String attr : reqAttrs) {
attrsInOCs.add(attr);
}
}
} catch (ServiceException e) {
ZimbraLog.account.debug("unable to lookup attributes for objectclass: " + oc, e);
}
}
} catch (ServiceException e) {
ZimbraLog.account.warn("unable to get LDAP schema", e);
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.cs.ldap.ZLdapSchema in project zm-mailbox by Zimbra.
the class LdapProvisioning method dumpLdapSchema.
@Override
public void dumpLdapSchema(PrintWriter writer) throws ServiceException {
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.GET_SCHEMA);
ZLdapSchema schema = zlc.getSchema();
for (ZLdapSchema.ZObjectClassDefinition oc : schema.getObjectClasses()) {
writer.println(oc.getName());
}
// TODO print more stuff
} catch (ServiceException e) {
ZimbraLog.account.warn("unable to get LDAP schema", e);
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.cs.ldap.ZLdapSchema in project zm-mailbox by Zimbra.
the class LdapProvisioning method searchOCsForSuperClasses.
@Override
public void searchOCsForSuperClasses(Map<String, Set<String>> ocs) {
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.GET_SCHEMA);
ZLdapSchema schema = zlc.getSchema();
for (Map.Entry<String, Set<String>> entry : ocs.entrySet()) {
String oc = entry.getKey();
Set<String> superOCs = entry.getValue();
try {
ZimbraLog.account.debug("Looking up OC: " + oc);
ZLdapSchema.ZObjectClassDefinition ocSchema = schema.getObjectClass(oc);
if (ocSchema != null) {
List<String> superClasses = ocSchema.getSuperiorClasses();
for (String superOC : superClasses) {
superOCs.add(superOC.toLowerCase());
}
}
} catch (ServiceException e) {
ZimbraLog.account.debug("unable to load LDAP schema extension for objectclass: " + oc, e);
}
}
} catch (ServiceException e) {
ZimbraLog.account.warn("unable to get LDAP schema", e);
} finally {
LdapClient.closeContext(zlc);
}
}
Aggregations