public Map<String, Object> get() { if (handleEndOfResults()) return null; try { Map<String, Object> entry = new LinkedHashMap<>(attributes.size() + 1); LDAPEntry en = null; en = lsr.next(); entry.put("dn", en.getDN()); if (attributes != null && attributes.size() > 0) { for (int col = 0; col < attributes.size(); col++) { Object val = readValue(en.getAttributeSet().getAttribute(attributes.get(col))); if (val != null) entry.put(attributes.get(col),val ); } } else { // make it dynamic Iterator<LDAPAttribute> iter = en.getAttributeSet().iterator(); while (iter.hasNext()) { LDAPAttribute attr = iter.next(); Object val = readValue(attr); if (val != null) entry.put(attr.getName(), readValue(attr)); } } //System.out.println("entry " + entry); return entry; } catch (LDAPException e) { e.printStackTrace(); throw new RuntimeException("Error getting next ldap entry " + e.getLDAPErrorMessage()); } }
@Test public void testLoadLDAP() throws Exception { Map<String, Object> connParms = new HashMap<>(); connParms.put("ldapHost", "ldap.forumsys.com"); connParms.put("ldapPort", 389l); connParms.put("loginDN", "cn=read-only-admin,dc=example,dc=com"); connParms.put("loginPW", "password"); LoadLdap.LDAPManager mgr = new LoadLdap.LDAPManager(LoadLdap.getConnectionMap(connParms)); Map<String, Object> searchParms = new HashMap<>(); searchParms.put("searchBase", "dc=example,dc=com"); searchParms.put("searchScope", "SCOPE_ONE"); searchParms.put("searchFilter", "(&(objectClass=*)(uid=training))"); ArrayList<String> ats = new ArrayList<>(); ats.add("uid"); searchParms.put("attributes", ats); LDAPSearchResults results = mgr.doSearch(searchParms); LDAPEntry le = results.next(); assertEquals("uid=training,dc=example,dc=com", le.getDN()); assertEquals("training", le.getAttribute("uid").getStringValue()); }
/** * Constructs an empty entry. * * @see <a href="../../../../api/com/novell/ldap/LDAPEntry.html#LDAPEntry()"> com.novell.ldap.LDAPEntry.LDAPEntry()</a> */ public LDAPEntry() { entry = new com.novell.ldap.LDAPEntry(); return; }
/** * This method does DSML serialization of the instance. * * @param oout Outputstream where the serialzed data has to be written * * @throws IOException if write fails on OutputStream */ public void writeDSML(java.io.OutputStream oout) throws java.io.IOException { java.io.Writer out=new java.io.OutputStreamWriter(oout,"UTF-8"); out.write("<LDAPEntry dn=\""); out.write(getDN()); out.write("\">"); Iterator i = getAttributeSet().iterator(); while (i.hasNext()){ writeAttribute( (LDAPAttribute) i.next(),out); } newLine(0,out); out.write("</LDAPEntry>"); out.close(); } /**
/** * Returns the distinguished name of the entry. * * @see <a href="../../../../api/com/novell/ldap/LDAPEntry.html#getDN()"> com.novell.ldap.LDAPEntry.getDN()</a> */ public String getDN() { return entry.getDN(); }
DN dn = new DN(entry.getDN()); String objectClass = entry.getAttribute("objectClass").getStringValue(); add.setObjectClass(objectClass); Iterator it = entry.getAttributeSet().iterator();
(LDAPEntry)LDAPEntry.readDSML(istream); this.dn = readObject.getDN(); this.attrs = readObject.getAttributeSet();
/** * Returns the attributes matching the specified attrName. * * @see <a href="../../../../api/com/novell/ldap/LDAPEntry.html#getAttribute(java.lang.String)"> com.novell.ldap.LDAPEntry.getAttribute(String)</a> */ public LDAPAttribute getAttribute(String attrName) { com.novell.ldap.LDAPAttribute attr; if( (attr = entry.getAttribute(attrName)) == null) { return null; } return new LDAPAttribute( attr); }
buff.append(getDN()); buff.append("\">"); Iterator i = getAttributeSet().iterator(); while (i.hasNext()){ writeAttribute( (LDAPAttribute) i.next(),buff);
/** * Returns the attribute set of the entry. * * @see <a href="../../../../api/com/novell/ldap/LDAPEntry.html#getAttributeSet()"> com.novell.ldap.LDAPEntry.getAttributeSet()</a> */ public LDAPAttributeSet getAttributeSet() { return new LDAPAttributeSet( entry.getAttributeSet()); }
/** * Compares this object to the specified object for order. * * @see <a href="../../../../api/com/novell/ldap/LDAPEntry.html#compareTo(java.lang.Object)"> com.novell.ldap.LDAPEntry.compareTo(Object)</a> */ public int compareTo(Object entry){ return this.entry.compareTo( ((LDAPEntry)entry).getWrappedObject() ); } }
/** * Always returns the value set by {@link #setUserType(String)}. * Default is <code>null</code> * * @return the value cached by {@link #setUserType(String)}. */ public String mapLdapEntryToSakaiUserType(LDAPEntry ldapEntry, LdapAttributeMapper mapper) { if ( log.isDebugEnabled() ) { log.debug("mapLdapEntryToSakaiUserType(): returning user type [" + userType + "] for [entry DN = " + ldapEntry.getDN() + "]"); } return userType; }
LDAPAttribute identifier = entry.getAttribute(identifierAttribute); if (identifier != null) return identifier.getStringValue();
/** * Returns an attribute set from the entry, consisting of only those * attributes matching the specified subtypes. * * @see <a href="../../../../api/com/novell/ldap/LDAPEntry.html#getAttributeSet(java.lang.String)"> com.novell.ldap.LDAPEntry.getAttributeSet(String)</a> */ public LDAPAttributeSet getAttributeSet(String subtype) { return new LDAPAttributeSet( entry.getAttributeSet( subtype)); }
LDAPEntry entry1 = searchResults.next(); System.out.println("\n" + entry1.getDN()); System.out.println(" Attributes: "); LDAPAttributeSet attributeSet1 = entry1.getAttributeSet(); Iterator allAttributes1 = attributeSet1.iterator(); while(allAttributes1.hasNext()) { LDAPAttribute attribute = (LDAPAttribute)allAttributes1.next(); String attrName = attribute.getName(); System.out.println(" " + attrName); Enumeration allValues1 = attribute.getStringValues(); while(allValues1.hasMoreElements()) { oid = (String) allValues1.nextElement(); if ( (attrName.equalsIgnoreCase("supportedExtension")) || (attrName.equalsIgnoreCase("supportedControl"))) { System.out.println(" " + oid); } } }
protected void setUserDataDn(LDAPEntry entry, LdapUserData targetUserData) { targetUserData.setProperty( AttributeMappingConstants.USER_DN_PROPERTY, entry.getDN()); }
ldapEntry.getDN() + "]"); log.debug("getUserTypeAttribute(): failed to find attribute mapping [logical attr name = " + logicalAttributeName + "][entry DN = " + ldapEntry.getDN() + "]"); LDAPAttribute attr = ldapEntry.getAttribute(attrName); if ( attr == null ) { if ( log.isDebugEnabled() ) { log.debug("getUserTypeAttribute(): entry had no Sakai user type attr [physical attr name = " + attrName + "][entry DN = " + ldapEntry.getDN() + "]");
one = entry1.getAttribute(sortByNames[i]); two = entry2.getAttribute(sortByNames[i]); if ((one != null) && (two != null)){ first = one.getStringValueArray();
return Collections.<String, String>emptyMap(); LDAPAttributeSet attrSet = userEntry.getAttributeSet(); if (attrSet == null) return Collections.<String, String>emptyMap();
/** * Constructs a new entry with the specified distinguished name and with * an empty attribute set. * * @see <a href="../../../../api/com/novell/ldap/LDAPEntry.html#LDAPEntry(java.lang.String)"> com.novell.ldap.LDAPEntry.LDAPEntry(String)</a> */ public LDAPEntry(String dn) { entry = new com.novell.ldap.LDAPEntry(dn); return; }