Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8353247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:12:05+00:00 2026-06-09T09:12:05+00:00

I’m trying to get a DN ( could be more than one ) of

  • 0

I’m trying to get a DN ( could be more than one ) of a user when the only parameter i have is the user-id

also i’m using UnboundID LDap SDK as you can see:

public String getCustomerAdminDN(String uid)
{

    String result =null;
    String filter = "uid=" +uid;
    try {
        SearchResult searchResult = this.ldapConnection.search("",SearchScope.SUB,filter);

        result = searchResult.getMatchedDN();
    } catch (LDAPSearchException e) {
        throw new RuntimeException("Error in the searching query :" + e.getMessage());
    }

  return result;
}

let’s assume my uid belongs to the following DN

Thanks from a head

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:12:06+00:00Added an answer on June 9, 2026 at 9:12 am

    The issue in this case is that the “matched DN” element isn’t what you think it is. It isn’t the DN of an entry that matched the search criteria (which could in fact be zero, one or multiple entries). The matched DN element of a response may be supplied if the target of the operation doesn’t exist. For a search operation, if you had specified a search base DN that doesn’t exist, then the matched DN might specify the DN of the closest entry to what you specified that actually does exist in the server. For example, if you had specified a search base DN of “ou=nonexistent,dc=example,dc=com”, which doesn’t exist but the entry “dc=example,dc=com” entry does exist, then the server may return a matched DN value of “dc=example,dc=com”.

    If your search matches one or more entries, then (unless you used a search result listener, which wasn’t the case in the example you provided above), the matching entries will be accessible through the getSearchEntries method. For example:

     List<SearchResultEntry> searchEntries = searchResult.getSearchEntries();
     if (searchEntries.size() != 1)
     {
       // The search didn't match exactly one entry.
     }
     else
     {
       SearchResultEntry entry = searchEntries.get(0);
       result = entry.getDN();
     }
    

    Also, you should be careful when constructing filters from their string representations when part of the value may come from user input, as that may allow for some kind of injection attack. LDAP injection is more difficult and usually more benign than SQL is, but it is not entirely nonexistent. It is therefore recommended that instead of:

     String filter = "uid=" + uid;
    

    you use:

     Filter filter = Filter.createEqualityFilter("uid", uid);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.