Package netscape.ldap

Examples of netscape.ldap.LDAPModificationSet


        // .. nodattrs="cn|uid=x" actions="d r a"
        String actions[] = split( hr.get("actions") );
        if ( actions == null ){
          return;
        }
              LDAPModificationSet attrs = new LDAPModificationSet();
                addattrs(hr.get("modattr"), attrs, actions);
        System.out.println ( attrs );
              ld.modify( dn, attrs );
            } else if (hr.get("delete") != null) {
                ld.delete(dn);
            } else if (hr.get("add") != null) {
                String add = hr.get("add");

                System.out.println(add);

                LDAPAttributeSet attrs = new LDAPAttributeSet();
                LDAPAttribute attr = new LDAPAttribute("objectclass");

                for (int i = 0; i < objectclass_values.length; i++) {
                    attr.addValue(objectclass_values[i]);
                }

                attrs.add(attr);

                // The add string will look like this: cn=x,y|sn=u,z|x3=p...

                addattrs(add, attrs, null);
        //        attrs.add(new LDAPAttribute("uid", "x1"));
View Full Code Here


    public void importEntry( LDAPEntry entry, int policy )
  throws LDAPException
    {
  LDAPEntry           existing;
  LDAPModificationSet modifs;
  LDAPAttributeSet    attrSet;
  LDAPAttribute       attr;
  int                 i;
  Enumeration         enumeration;

  if ( entry.getAttributeSet() == null ||
       entry.getAttributeSet().size() == 0 ) {

      if ( ( policy & ImportDescriptor.Policy.DeleteEmpty ) != 0 ) {
    try {
        _conn.read( entry.getDN() );
        _conn.delete( entry.getDN() );
        notify( entry.getDN(), ImportEventListener.Deleted );
    } catch ( LDAPException except ) {
        // Object does not exist, was not removed, ignore.
        // Anything else, we must complain.
        if ( except.getLDAPResultCode() != LDAPException.NO_SUCH_OBJECT )
      throw except;
        notify( entry.getDN(), ImportEventListener.Ignored );
    }
      } else {
    notify( entry.getDN(), ImportEventListener.Ignored );
      }

  } else {

      try {
    existing = _conn.read( entry.getDN() );

    modifs = new LDAPModificationSet();
    attrSet = entry.getAttributeSet();
    for ( i = 0 ; i < attrSet.size() ; ++i ) {
                    attr = attrSet.elementAt( i );
                    if ( existing.getAttributeSet().getAttribute( attr.getName() ) != null ) {
                        if ( ( policy & ImportDescriptor.Policy.NewAttrOnly ) == 0 ) {
                            if ( attr.size() > 0 ) {
                                modifs.add( LDAPModification.REPLACE, attr );
                            } else {
                                modifs.add( LDAPModification.DELETE, attr );
                            }
                        }
                    } else {
                        if ( ( policy & ImportDescriptor.Policy.UpdateOnly ) == 0 ) {
                            if ( attr.size() > 0 ) {
                                modifs.add( LDAPModification.ADD, attr );
                            }
                        }
                    }
                }
                if ( ( policy & ImportDescriptor.Policy.ReplaceAttr ) != 0 ) {
        enumeration = existing.getAttributeSet().getAttributes();
        while ( enumeration.hasMoreElements() ) {
      attr = (LDAPAttribute) enumeration.nextElement();
      if ( entry.getAttribute( attr.getName() ) == null ) {
          modifs.add( LDAPModification.DELETE, attr );
      }
        }
    }
    if ( modifs.size() > 0 ) {
        _conn.modify( entry.getDN(), modifs );
        notify( entry.getDN(), ImportEventListener.Refreshed );
    } else {
        notify( entry.getDN(), ImportEventListener.Ignored );
    }
View Full Code Here

    public void importEntry( LDAPEntry entry, int policy )
  throws LDAPException
    {
  LDAPEntry           existing;
  LDAPModificationSet modifs;
  LDAPAttributeSet    attrSet;
  LDAPAttribute       attr;
  int                 i;
  Enumeration         enumeration;

  if ( entry.getAttributeSet() == null ||
       entry.getAttributeSet().size() == 0 ) {

      if ( ( policy & ImportDescriptor.Policy.DeleteEmpty ) != 0 ) {
    try {
        _conn.read( entry.getDN() );
        _conn.delete( entry.getDN() );
        notify( entry.getDN(), ImportEventListener.Deleted );
    } catch ( LDAPException except ) {
        // Object does not exist, was not removed, ignore.
        // Anything else, we must complain.
        if ( except.getLDAPResultCode() != LDAPException.NO_SUCH_OBJECT )
      throw except;
        notify( entry.getDN(), ImportEventListener.Ignored );
    }
      } else {
    notify( entry.getDN(), ImportEventListener.Ignored );
      }

  } else {

      try {
    existing = _conn.read( entry.getDN() );

    modifs = new LDAPModificationSet();
    attrSet = entry.getAttributeSet();
    for ( i = 0 ; i < attrSet.size() ; ++i ) {
                    attr = attrSet.elementAt( i );
                    if ( existing.getAttributeSet().getAttribute( attr.getName() ) != null ) {
                        if ( ( policy & ImportDescriptor.Policy.NewAttrOnly ) == 0 ) {
                            if ( attr.size() > 0 ) {
                                modifs.add( LDAPModification.REPLACE, attr );
                            } else {
                                modifs.add( LDAPModification.DELETE, attr );
                            }
                        }
                    } else {
                        if ( ( policy & ImportDescriptor.Policy.UpdateOnly ) == 0 ) {
                            if ( attr.size() > 0 ) {
                                modifs.add( LDAPModification.ADD, attr );
                            }
                        }
                    }
                }
                if ( ( policy & ImportDescriptor.Policy.ReplaceAttr ) != 0 ) {
        enumeration = existing.getAttributeSet().getAttributes();
        while ( enumeration.hasMoreElements() ) {
      attr = (LDAPAttribute) enumeration.nextElement();
      if ( entry.getAttribute( attr.getName() ) == null ) {
          modifs.add( LDAPModification.DELETE, attr );
      }
        }
    }
    if ( modifs.size() > 0 ) {
        _conn.modify( entry.getDN(), modifs );
        notify( entry.getDN(), ImportEventListener.Refreshed );
    } else {
        notify( entry.getDN(), ImportEventListener.Ignored );
    }
View Full Code Here

TOP

Related Classes of netscape.ldap.LDAPModificationSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.