/** * Constructs an attribute that has a single string value. * * @see <a href="../../../../api/com/novell/ldap/LDAPAttribute.html#LDAPAttribute(java.lang.String, java.lang.String)"> com.novell.ldap.LDAPAttribute.LDAPAttribute(String, String)</a> */ public LDAPAttribute(String attrName, String attrString) { this.attr = new com.novell.ldap.LDAPAttribute(attrName, attrString); return; }
/** * Constructs an attribute that has an array of string values. * * @see <a href="../../../../api/com/novell/ldap/LDAPAttribute.html#LDAPAttribute(java.lang.String, java.lang.String[])"> com.novell.ldap.LDAPAttribute.LDAPAttribute(String, String[])</a> */ public LDAPAttribute(String attrName, String[] attrStrings) { this.attr = new com.novell.ldap.LDAPAttribute(attrName, attrStrings); return; }
/** * Constructs an attribute with no values. * * @see <a href="../../../../api/com/novell/ldap/LDAPAttribute.html#LDAPAttribute(java.lang.String)"> com.novell.ldap.LDAPAttribute.LDAPAttribute(String)</a> */ public LDAPAttribute(String attrName) { this.attr = new com.novell.ldap.LDAPAttribute(attrName); return; }
/** * Constructs an attribute with a byte-formatted value. * * @see <a href="../../../../api/com/novell/ldap/LDAPAttribute.html#LDAPAttribute(java.lang.String, byte[])"> com.novell.ldap.LDAPAttribute.LDAPAttribute(String, byte[])</a> */ public LDAPAttribute(String attrName, byte[] attrBytes) { this.attr = new com.novell.ldap.LDAPAttribute(attrName, attrBytes); return; }
mods.add(LDAPModification.REPLACE, new LDAPAttribute("email","mytest@abc.com"));
String myEntryDN = "cn=Barbara Jensen,ou=Product Development,o=Ace Industry,c=US"; LDAPAttribute attrEmail = new LDAPAttribute( "mail", "babs@aceindustry.com" ); LDAPModification singleChange = new LDAPModification( LDAPModification.REPLACE, attrEmail ); myConn.modify( myEntryDN, singleChange );
protected void endElement() { Iterator valueiterator = valuelist.iterator(); LDAPAttribute attr = new LDAPAttribute(attrName); while (valueiterator.hasNext()) { attr.addValue((byte[])valueiterator.next()); } setObject(attr); valuelist.clear(); }
/** * Constructs an attribute with copies of all values of the input * attribute. * * @see <a href="../../../../api/com/novell/ldap/LDAPAttribute.html#LDAPAttribute(com.novell.ldap.LDAPAttribute)"> com.novell.ldap.LDAPAttribute.LDAPAttribute(LDAPAttribute)</a> */ public LDAPAttribute(LDAPAttribute attr) { com.novell.ldap.LDAPAttribute at = null; if( attr != null) { at = attr.getWrappedObject(); } this.attr = new com.novell.ldap.LDAPAttribute(at); return; }
protected void endElement() { LDAPAttribute attr = new LDAPAttribute(attrName); if (!valuelist.isEmpty()) { Iterator valueiterator = valuelist.iterator(); while (valueiterator.hasNext()) { attr.addValue((byte[])valueiterator.next()); } } LDAPModification mod = new LDAPModification(operation,attr); setObject(mod); } protected void addValue(String tag, Object value) {
/** * Check if provided password is correct provided users's password. * * @param userDN the user. * @param password the password. * @param passwordField the name of the LDAP field containing the password. * @return true if the password is valid, false otherwise. */ public boolean checkPassword(String userDN, String password, String passwordField) { try { LDAPAttribute attribute = new LDAPAttribute(passwordField, password); return this.connection.compare(userDN, attribute); } catch (LDAPException e) { if (e.getResultCode() == LDAPException.NO_SUCH_OBJECT) { if (LOG.isDebugEnabled()) { LOG.debug("Unable to locate user_dn:" + userDN, e); } } else if (e.getResultCode() == LDAPException.NO_SUCH_ATTRIBUTE) { if (LOG.isDebugEnabled()) { LOG.debug("Unable to verify password because userPassword attribute not found.", e); } } else { if (LOG.isDebugEnabled()) { LOG.debug("Unable to verify password", e); } } } return false; }
/** * Check if provided password is correct provided users's password. * * @param userDN the user. * @param password the password. * @param passwordField the name of the LDAP field containing the password. * @return true if the password is valid, false otherwise. */ public boolean checkPassword(String userDN, String password, String passwordField) { try { LDAPAttribute attribute = new LDAPAttribute(passwordField, password); return this.connection.compare(userDN, attribute); } catch (LDAPException e) { if (e.getResultCode() == LDAPException.NO_SUCH_OBJECT) { LOGGER.debug("Unable to locate user_dn [{}]", userDN, e); } else if (e.getResultCode() == LDAPException.NO_SUCH_ATTRIBUTE) { LOGGER.debug("Unable to verify password because userPassword attribute not found.", e); } else { LOGGER.debug("Unable to verify password", e); } } return false; }
LDAPConnection myCon = new LDAPConnection("localhost",389); LDAPModificationSet mods = new LDAPModificationSet(); mods.add(LDAPModification.DELETE, new LDAPAttribute("notifyTo")); myCon.modify("uid=test1, ou=People, o=domain.com, o=isp", mods);
if (o instanceof String) { String attrib = (String) attribs.get(name); LDAPAttribute ldapAttrib = new LDAPAttribute(name); if (attrib == null) { attrib = ""; List l = (List) attribs.get(name); Iterator vals = l.iterator(); LDAPAttribute ldapAttrib = new LDAPAttribute(name); while (vals.hasNext()) { String attrib = (String) vals.next(); LDAPAttribute ldapAttrib = new LDAPAttribute(id.getType().substring(id.getType().lastIndexOf('#') + 1)); ldapAttrib.addValue(id.getId());
attr = new LDAPAttribute(attrName); if (nextField.charAt(index+1)==':') { attr = new LDAPAttribute(attrName);
attrSet.add(new LDAPAttribute(attrName));
LDAPAttribute at = new LDAPAttribute(attrName); for (int i = 0; i < attributeValues.size(); i++) { at.addValue((byte[]) attributeValues.get(i)); attr = new LDAPAttribute(attrName); attrSet.add(attr);
ASN1SetOf avalue = (ASN1SetOf)attrArray[1]; ASN1Object[] valueArray = avalue.toArray(); LDAPAttribute attr = new LDAPAttribute( name);
/** * Constructs an LDAPEntry that represents the add request * * @return an LDAPEntry that represents the add request. */ public LDAPEntry getEntry() { RfcAddRequest addreq = (RfcAddRequest)getASN1Object().getRequest(); LDAPAttributeSet attrs = new LDAPAttributeSet(); // Build the list of attributes ASN1Object[] seqArray = addreq.getAttributes().toArray(); for(int i = 0; i < seqArray.length; i++) { RfcAttributeTypeAndValues seq = (RfcAttributeTypeAndValues)seqArray[i]; LDAPAttribute attr = new LDAPAttribute(((ASN1OctetString)seq.get(0)).stringValue()); // Add the values to the attribute ASN1SetOf set = (ASN1SetOf)seq.get(1); Object[] setArray = set.toArray(); for(int j = 0; j < setArray.length; j++) { attr.addValue(((ASN1OctetString)setArray[j]).byteValue()); } attrs.add(attr); } return new LDAPEntry( getASN1Object().getRequestDN(), attrs); }
/** * Returns the entry of a server's search response. * * @return The LDAPEntry associated with this LDAPSearchResult */ public LDAPEntry getEntry() { if( entry == null) { LDAPAttributeSet attrs = new LDAPAttributeSet(); ASN1Sequence attrList = ((RfcSearchResultEntry)message.getResponse()).getAttributes(); ASN1Object[] seqArray = attrList.toArray(); for(int i = 0; i < seqArray.length; i++) { ASN1Sequence seq = (ASN1Sequence)seqArray[i]; LDAPAttribute attr = new LDAPAttribute(((ASN1OctetString)seq.get(0)).stringValue()); ASN1Set set = (ASN1Set)seq.get(1); Object[] setArray = set.toArray(); for(int j = 0; j < setArray.length; j++) { attr.addValue(((ASN1OctetString)setArray[j]).byteValue()); } attrs.add(attr); } entry = new LDAPEntry( ((RfcSearchResultEntry)message.getResponse()).getObjectName().stringValue(), attrs); } return entry; }