@Override public boolean apply(final Attribute attribute) { return groupNameId.equalsIgnoreCase(attribute.getID()); } });
public Object mapFromContext(Object ctx) { DirContextAdapter adapter = (DirContextAdapter) ctx; Map<String, List<String>> record = new HashMap<String, List<String>>(); if (attributeNames == null || attributeNames.length == 0) { try { for (NamingEnumeration ae = adapter.getAttributes().getAll(); ae .hasMore();) { Attribute attr = (Attribute) ae.next(); extractStringAttributeValues(adapter, record, attr.getID()); } } catch (NamingException x) { org.springframework.ldap.support.LdapUtils .convertLdapException(x); } } else { for (String attributeName : attributeNames) { extractStringAttributeValues(adapter, record, attributeName); } } record.put(DN_KEY, Arrays.asList(getAdapterDN(adapter))); set.add(record); return null; } };
for (Enumeration vals = attr.getAll(); vals.hasMoreElements();) { Object elem = vals.nextElement(); if ("PTR".equals(attr.getID()) && elem != null) { return elem.toString();
Attribute attr = (Attribute) ae.next(); if (attr.getID().equals("memberOf")) {
public void updateUser(UserDetails user) { DistinguishedName dn = usernameMapper.buildDn(user.getUsername()); logger.debug("Updating user '" + user.getUsername() + "' with DN '" + dn + "'"); List<GrantedAuthority> authorities = getUserAuthorities(dn, user.getUsername()); DirContextAdapter ctx = loadUserAsContext(dn, user.getUsername()); ctx.setUpdateMode(true); copyToContext(user, ctx); // Remove the objectclass attribute from the list of mods (if present). List<ModificationItem> mods = new LinkedList<>(Arrays.asList(ctx .getModificationItems())); ListIterator<ModificationItem> modIt = mods.listIterator(); while (modIt.hasNext()) { ModificationItem mod = (ModificationItem) modIt.next(); Attribute a = mod.getAttribute(); if ("objectclass".equalsIgnoreCase(a.getID())) { modIt.remove(); } } template.modifyAttributes(dn, mods.toArray(new ModificationItem[mods.size()])); // template.rebind(dn, ctx, null); // Remove the old authorities and replace them with the new one removeAuthorities(dn, authorities); addAuthorities(dn, user.getAuthorities()); }
String fieldName = attr.getID(); if ( !fieldsl.contains( fieldName ) ) { fieldsl.add( fieldName );
Attribute attr = (Attribute) ae.next(); if (attr.getID().equals("memberOf")) {
Hashtable<String, Object> env = new Hashtable<String, Object>(); env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory"); env.put("java.naming.provider.url", "dns://<your DNS server>"); DirContext ictx = new InitialDirContext(env); Attributes attrs = ictx.getAttributes("www.heise.de", new String[] {"A", "AAAA"}); NamingEnumeration<? extends Attribute> e = attrs.getAll(); while(e.hasMoreElements()) { Attribute a = e.next(); System.out.println(a.getID() + " = " + a.get()); }
private LdapAttribute(Attribute attribute) throws NamingException { this.name = attribute.getID(); NamingEnumeration nem = attribute.getAll(); while(nem.hasMoreElements()) { Object valueObj = nem.next(); if (valueObj instanceof String) this.values.add(valueObj.toString()); } }
public Map<String, Attribute> mapFromAttributes(Attributes attrs) throws NamingException { Map<String, Attribute> map = new HashMap<>(); NamingEnumeration<? extends Attribute> attrEnum = attrs.getAll(); while (attrEnum.hasMore()) { Attribute att = attrEnum.next(); map.put(att.getID(), att); } return map; } };
public Map<String, Attribute> mapFromAttributes(Attributes attrs) throws NamingException { Map<String, Attribute> map = new HashMap<>(); NamingEnumeration<? extends Attribute> attrEnum = attrs.getAll(); while (attrEnum.hasMore()) { Attribute att = attrEnum.next(); map.put(att.getID(), att); } return map; } };
@Override public Attribute put(Attribute attr) { Assert.notNull(attr, "Attribute must not be null"); NameAwareAttribute newAttribute = new NameAwareAttribute(attr); attributes.put(attr.getID().toLowerCase(), newAttribute); return newAttribute; }
public Map<String, Attribute> mapFromAttributes(Attributes attrs) throws NamingException { Map<String, Attribute> map = new HashMap<>(); NamingEnumeration<? extends Attribute> attrEnum = attrs.getAll(); while (attrEnum.hasMore()) { Attribute att = attrEnum.next(); map.put(att.getID(), att); } return map; } };
public Map<String, Attribute> mapFromAttributes(Attributes attrs) throws NamingException { Map<String, Attribute> map = new HashMap<>(); NamingEnumeration<? extends Attribute> attrEnum = attrs.getAll(); while (attrEnum.hasMore()) { Attribute att = attrEnum.next(); map.put(att.getID(), att); } return map; } };
/** * Checks if an entry has a specific attribute. * * This method simply calls exists(String) with the attribute name. * * @param attr the attribute to check. * @return true if attribute exists in entry. */ protected final boolean exists(Attribute attr) { return exists(attr.getID()); }
private static void printAttrs(Attributes attrs) throws NamingException { NamingEnumeration<? extends Attribute> attrsEnum = attrs.getAll(); while (attrsEnum.hasMore()) { Attribute currentAttr = attrsEnum.next(); outstream.print(String.format("%1$s:", currentAttr.getID())); NamingEnumeration<?> valuesEnum = currentAttr.getAll(); while (valuesEnum.hasMoreElements()) { outstream.print(String.format("%1$s ", valuesEnum.nextElement().toString())); } outstream.println(); } }
private static void printAttrs(Attributes attrs) throws NamingException { NamingEnumeration<? extends Attribute> attrsEnum = attrs.getAll(); while (attrsEnum.hasMore()) { Attribute currentAttr = attrsEnum.next(); outstream.print(String.format("%1$s:", currentAttr.getID())); NamingEnumeration<?> valuesEnum = currentAttr.getAll(); while (valuesEnum.hasMoreElements()) { outstream.print(String.format("%1$s ", valuesEnum.nextElement().toString())); } outstream.println(); } }
/** * Checks to see numbers of values of attributes conforms to the schema */ private void assertNumberOfAttributeValuesValid( Attribute attribute ) throws InvalidAttributeValueException, NamingException { AttributeTypeRegistry registry = this.globalRegistries.getAttributeTypeRegistry(); if ( attribute.size() > 1 && registry.lookup( attribute.getID() ).isSingleValue() ) { throw new LdapInvalidAttributeValueException( "More than one value has been provided " + "for the single-valued attribute: " + attribute.getID(), ResultCodeEnum.CONSTRAINTVIOLATION ); } }
public Map<String, Attribute> mapFromAttributes(Attributes attrs) throws NamingException { Map<String, Attribute> map = new HashMap<>(); NamingEnumeration<? extends Attribute> attrEnum = attrs.getAll(); while (attrEnum.hasMore()) { Attribute att = attrEnum.next(); map.put(att.getID(), att); } return map; } };