Package com.unboundid.ldap.sdk

Examples of com.unboundid.ldap.sdk.SearchResult


    assertNull(userOneModel);
  }

  @Test
  public void checkIfUsersConfContainsAllUsersFromSampleDataLdif() throws Exception {
    SearchResult searchResult = ds.search("OU=Users,OU=UserControl,OU=MyOrganization,DC=MyDomain", SearchScope.SUB, "objectClass=person");
    assertEquals("Number of ldap users in gitblit user model", searchResult.getEntryCount(), countLdapUsersInUserManager());
  }
View Full Code Here


          String accountBase = settings.getString(Keys.realm.ldap.accountBase, "");
          String uidAttribute = settings.getString(Keys.realm.ldap.uid, "uid");
          String accountPattern = settings.getString(Keys.realm.ldap.accountPattern, "(&(objectClass=person)(sAMAccountName=${username}))");
          accountPattern = StringUtils.replace(accountPattern, "${username}", "*");

          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;
              }
View Full Code Here

        // Find the logging in user's DN
        String accountBase = settings.getString(Keys.realm.ldap.accountBase, "");
        String accountPattern = settings.getString(Keys.realm.ldap.accountPattern, "(&(objectClass=person)(sAMAccountName=${username}))");
        accountPattern = StringUtils.replace(accountPattern, "${username}", escapeLDAPSearchFilter(simpleUsername));

        SearchResult result = doSearch(ldapConnection, accountBase, accountPattern);
        if (result != null && result.getEntryCount() == 1) {
          SearchResultEntry loggingInUser = result.getSearchEntries().get(0);
          String loggingInUserDN = loggingInUser.getDN();

          if (alreadyAuthenticated || isAuthenticated(ldapConnection, loggingInUserDN, new String(password))) {
            logger.debug("LDAP authenticated: " + username);
View Full Code Here

    // Fill in attributes into groupMemberPattern
    for (Attribute userAttribute : loggingInUser.getAttributes()) {
      groupMemberPattern = StringUtils.replace(groupMemberPattern, "${" + userAttribute.getName() + "}", escapeLDAPSearchFilter(userAttribute.getValue()));
    }

    SearchResult teamMembershipResult = doSearch(ldapConnection, groupBase, true, groupMemberPattern, Arrays.asList("cn"));
    if (teamMembershipResult != null && teamMembershipResult.getEntryCount() > 0) {
      for (int i = 0; i < teamMembershipResult.getEntryCount(); i++) {
        SearchResultEntry teamEntry = teamMembershipResult.getSearchEntries().get(i);
        String teamName = teamEntry.getAttribute("cn").getValue();

        TeamModel teamModel = userManager.getTeamModel(teamName);
        if (teamModel == null) {
          teamModel = createTeamFromLdap(teamEntry);
View Full Code Here

  private void getEmptyTeamsFromLdap(LDAPConnection ldapConnection) {
    logger.info("Start fetching empty teams from ldap.");
    String groupBase = settings.getString(Keys.realm.ldap.groupBase, "");
    String groupMemberPattern = settings.getString(Keys.realm.ldap.groupEmptyMemberPattern, "(&(objectClass=group)(!(member=*)))");

    SearchResult teamMembershipResult = doSearch(ldapConnection, groupBase, true, groupMemberPattern, null);
    if (teamMembershipResult != null && teamMembershipResult.getEntryCount() > 0) {
      for (int i = 0; i < teamMembershipResult.getEntryCount(); i++) {
        SearchResultEntry teamEntry = teamMembershipResult.getSearchEntries().get(i);
        if (!teamEntry.hasAttribute("member")) {
          String teamName = teamEntry.getAttribute("cn").getValue();

          TeamModel teamModel = userManager.getTeamModel(teamName);
          if (teamModel == null) {
View Full Code Here

          String accountBase = settings.getString(Keys.realm.ldap.accountBase, "");
          String uidAttribute = settings.getString(Keys.realm.ldap.uid, "uid");
          String accountPattern = settings.getString(Keys.realm.ldap.accountPattern, "(&(objectClass=person)(sAMAccountName=${username}))");
          accountPattern = StringUtils.replace(accountPattern, "${username}", "*");

          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;
              }
View Full Code Here

        // Find the logging in user's DN
        String accountBase = settings.getString(Keys.realm.ldap.accountBase, "");
        String accountPattern = settings.getString(Keys.realm.ldap.accountPattern, "(&(objectClass=person)(sAMAccountName=${username}))");
        accountPattern = StringUtils.replace(accountPattern, "${username}", escapeLDAPSearchFilter(simpleUsername));

        SearchResult result = doSearch(ldapConnection, accountBase, accountPattern);
        if (result != null && result.getEntryCount() == 1) {
          SearchResultEntry loggingInUser = result.getSearchEntries().get(0);
          String loggingInUserDN = loggingInUser.getDN();

          if (alreadyAuthenticated || isAuthenticated(ldapConnection, loggingInUserDN, new String(password))) {
            logger.debug("LDAP authenticated: " + username);
View Full Code Here

    // Fill in attributes into groupMemberPattern
    for (Attribute userAttribute : loggingInUser.getAttributes()) {
      groupMemberPattern = StringUtils.replace(groupMemberPattern, "${" + userAttribute.getName() + "}", escapeLDAPSearchFilter(userAttribute.getValue()));
    }

    SearchResult teamMembershipResult = doSearch(ldapConnection, groupBase, true, groupMemberPattern, Arrays.asList("cn"));
    if (teamMembershipResult != null && teamMembershipResult.getEntryCount() > 0) {
      for (int i = 0; i < teamMembershipResult.getEntryCount(); i++) {
        SearchResultEntry teamEntry = teamMembershipResult.getSearchEntries().get(i);
        String teamName = teamEntry.getAttribute("cn").getValue();

        TeamModel teamModel = userManager.getTeamModel(teamName);
        if (teamModel == null) {
          teamModel = createTeamFromLdap(teamEntry);
View Full Code Here

  private void getEmptyTeamsFromLdap(LDAPConnection ldapConnection) {
    logger.info("Start fetching empty teams from ldap.");
    String groupBase = settings.getString(Keys.realm.ldap.groupBase, "");
    String groupMemberPattern = settings.getString(Keys.realm.ldap.groupEmptyMemberPattern, "(&(objectClass=group)(!(member=*)))");

    SearchResult teamMembershipResult = doSearch(ldapConnection, groupBase, true, groupMemberPattern, null);
    if (teamMembershipResult != null && teamMembershipResult.getEntryCount() > 0) {
      for (int i = 0; i < teamMembershipResult.getEntryCount(); i++) {
        SearchResultEntry teamEntry = teamMembershipResult.getSearchEntries().get(i);
        if (!teamEntry.hasAttribute("member")) {
          String teamName = teamEntry.getAttribute("cn").getValue();

          TeamModel teamModel = userManager.getTeamModel(teamName);
          if (teamModel == null) {
View Full Code Here

    assertNull(userOneModel);
  }

  @Test
  public void checkIfUsersConfContainsAllUsersFromSampleDataLdif() throws Exception {
    SearchResult searchResult = ds.search("OU=Users,OU=UserControl,OU=MyOrganization,DC=MyDomain", SearchScope.SUB, "objectClass=person");
    assertEquals("Number of ldap users in gitblit user model", searchResult.getEntryCount(), countLdapUsersInUserManager());
  }
View Full Code Here

TOP

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

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.