示例#1
0
  public void modifyEntry() throws Exception {
    String dn = "cn=config,cn=zimbra";
    GenericLdapConfig ldapConfig = getLdapConfig();

    ZLdapContext zlc = null;
    try {
      zlc = LdapClient.getContext(ldapConfig, LdapUsage.MOD);

      ZMutableEntry entry = LdapClient.createMutableEntry();
      entry.setAttr("description", "so this gets modified");
      zlc.replaceAttributes(dn, entry.getAttributes());
    } finally {
      // Note: this is important!!
      LdapClient.closeContext(zlc);
    }
  }
示例#2
0
 public void doVisit(String dn, ZAttributes ldapAttrs) throws ServiceException {
   ZMutableEntry entry = LdapClient.createMutableEntry();
   entry.setAttr(Provisioning.A_zimbraPasswordChangeListener, "");
   upgradeOp.replaceAttrs(modZlc, dn, entry);
 }
示例#3
0
  public void createEntry() throws Exception {
    // dn of entry to create
    String dn = "uid=user1,ou=people,dc=test,dc=com";

    GenericLdapConfig ldapConfig = getLdapConfig();

    ZLdapContext zlc = null;
    try {
      zlc = LdapClient.getContext(ldapConfig, LdapUsage.ADD);

      ZMutableEntry entry = LdapClient.createMutableEntry();
      entry.setDN(dn);

      entry.addAttr("objectClass", "inetOrgPerson");
      entry.addAttr("objectClass", "zimbraAccount");
      entry.addAttr("objectClass", "amavisAccount");

      entry.setAttr("uid", "user1");
      entry.setAttr("cn", "user1");
      entry.setAttr("sn", "lastname");
      entry.setAttr("zimbraAccountStatus", "active");
      entry.setAttr("zimbraId", "ba6198a3-bb49-4425-94b0-d4e9354e87b5");
      entry.addAttr("mail", "*****@*****.**");
      entry.addAttr("mail", "*****@*****.**");

      zlc.createEntry(entry);
    } finally {
      // Note: this is important!!
      LdapClient.closeContext(zlc);
    }
  }