Package com.unboundid.ldap.sdk

Examples of com.unboundid.ldap.sdk.Attribute


        final InMemoryListenerConfig listenerConfig = InMemoryListenerConfig.createLDAPConfig("default", port);
        final InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(new DN(baseDN));
        config.setListenerConfigs(listenerConfig);
        config.addAdditionalBindCredentials(authDN, authPassword);
        final InMemoryDirectoryServer server = new InMemoryDirectoryServer(config);
        server.add(new Entry(baseDN, new Attribute("objectclass", "domain", "top")));
        loadData(server, ldifFile);
        server.startListening();
        return server;
    }
View Full Code Here


          SearchResult result = doSearch(ldapConnection, accountBase, accountPattern);
          if (result != null && result.getEntryCount() > 0) {
            final Map<String, UserModel> ldapUsers = new HashMap<String, UserModel>();

            for (SearchResultEntry loggingInUser : result.getSearchEntries()) {
              Attribute uid = loggingInUser.getAttribute(uidAttribute);
              if (uid == null) {
                logger.error("Can not synchronize with LDAP, missing \"{}\" attribute", uidAttribute);
                continue;
              }
              final String username = uid.getValue();
              logger.debug("LDAP synchronizing: " + username);

              UserModel user = userManager.getUserModel(username);
              if (user == null) {
                user = new UserModel(username);
View Full Code Here

        for (Attribute userAttribute : userEntry.getAttributes()) {
          displayName = StringUtils.replace(displayName, "${" + userAttribute.getName() + "}", userAttribute.getValue());
        }
        user.displayName = displayName;
      } else {
        Attribute attribute = userEntry.getAttribute(displayName);
        if (attribute != null && attribute.hasValue()) {
          user.displayName = attribute.getValue();
        }
      }
    }

    // Get email address Attribute
    String email = settings.getString(Keys.realm.ldap.email, "");
    if (!StringUtils.isEmpty(email)) {
      if (email.contains("${")) {
        for (Attribute userAttribute : userEntry.getAttributes()) {
          email = StringUtils.replace(email, "${" + userAttribute.getName() + "}", userAttribute.getValue());
        }
        user.emailAddress = email;
      } else {
        Attribute attribute = userEntry.getAttribute(email);
        if (attribute != null && attribute.hasValue()) {
          user.emailAddress = attribute.getValue();
        }
      }
    }
  }
View Full Code Here

          SearchResult result = doSearch(ldapConnection, accountBase, accountPattern);
          if (result != null && result.getEntryCount() > 0) {
            final Map<String, UserModel> ldapUsers = new HashMap<String, UserModel>();

            for (SearchResultEntry loggingInUser : result.getSearchEntries()) {
              Attribute uid = loggingInUser.getAttribute(uidAttribute);
              if (uid == null) {
                logger.error("Can not synchronize with LDAP, missing \"{}\" attribute", uidAttribute);
                continue;
              }
              final String username = uid.getValue();
              logger.debug("LDAP synchronizing: " + username);

              UserModel user = userManager.getUserModel(username);
              if (user == null) {
                user = new UserModel(username);
View Full Code Here

        for (Attribute userAttribute : userEntry.getAttributes()) {
          displayName = StringUtils.replace(displayName, "${" + userAttribute.getName() + "}", userAttribute.getValue());
        }
        user.displayName = displayName;
      } else {
        Attribute attribute = userEntry.getAttribute(displayName);
        if (attribute != null && attribute.hasValue()) {
          user.displayName = attribute.getValue();
        }
      }
    }

    // Get email address Attribute
    String email = settings.getString(Keys.realm.ldap.email, "");
    if (!StringUtils.isEmpty(email)) {
      if (email.contains("${")) {
        for (Attribute userAttribute : userEntry.getAttributes()) {
          email = StringUtils.replace(email, "${" + userAttribute.getName() + "}", userAttribute.getValue());
        }
        user.emailAddress = email;
      } else {
        Attribute attribute = userEntry.getAttribute(email);
        if (attribute != null && attribute.hasValue()) {
          user.emailAddress = attribute.getValue();
        } else {
          // issue-456/ticket-134
          // allow LDAP to delete an email address
          user.emailAddress = null;
        }
View Full Code Here

        final InMemoryListenerConfig listenerConfig = InMemoryListenerConfig.createLDAPConfig("default", annotation.port());
        final InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(new DN(annotation.baseDN()));
        config.setListenerConfigs(listenerConfig);
        config.addAdditionalBindCredentials(annotation.authDN(), annotation.authPassword());
        final InMemoryDirectoryServer server = new InMemoryDirectoryServer(config);
        server.add(new Entry(annotation.baseDN(), new Attribute("objectclass", "domain", "top")));
        loadData(server);
        server.startListening();
        return server;
    }
View Full Code Here

                final List<Node> objectClassList = (List<Node>) objectClassXPath.selectNodes(entryNode);
                final String[] objectClasses = new String[objectClassList.size()];
                for (int j = 0; j < objectClasses.length; ++j) {
                    objectClasses[j] = objectClassList.get(j).getStringValue();
                }
                attributes.add(new Attribute("objectclass", objectClasses));
                for (final Node attributeNode : (List<Node>) attrXPath.selectNodes(entryNode)) {
                    final String attributeName = attributeNode.valueOf("@name");
                    final List<Node> attributeValueNodes = (List<Node>) attrValueXPath.selectNodes(attributeNode);
                    switch (attributeValueNodes.size()) {
                        case 0:
                            break;
                        case 1: {
                            final String attributeValue = attributeValueNodes.get(0).getStringValue();
                            attributes.add(new Attribute(attributeName, attributeValue));
                            break;
                        }
                        default: {
                            final String[] attributeValues = new String[attributeValueNodes.size()];
                            for (int j = 0; j < attributeValueNodes.size(); ++j) {
                                attributeValues[j] = attributeValueNodes.get(j).getStringValue();
                            }
                            attributes.add(new Attribute(attributeName, attributeValues));
                            break;
                        }
                    }
                }
                return new LDIFAddChangeRecord(dn, attributes);
View Full Code Here

            config.setListenerConfigs(listenerConfig);
            if (getAuthDn() != null) {
                config.addAdditionalBindCredentials(getAuthDn(), getPasswd());
            }
            server = new InMemoryDirectoryServer(config);
            server.add(new Entry(getRoot(), new Attribute("objectclass", "domain", "top")));
            if (getLdifFile() != null) {
                final InputStream in = new FileInputStream(getLdifFile());
                try {
                    final LDIFReader reader = new LDIFReader(in);
                    server.importFromLDIF(false, reader);
View Full Code Here

TOP

Related Classes of com.unboundid.ldap.sdk.Attribute

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.