7 Replies Latest reply: Jun 3, 2011 3:54 AM by EJP RSS

    Ldap search problem

    807422
      my directory struture is like
      ---------------------main
      -----------------------------ou=1
      -------------------------------------ou=2
      -------------------------------------users are here

      above is a structure where DC is main then two OU then the users i want to search through the users so any one can post some code
      for this i m trying it hard but not getting any result
        • 1. Re: Ldap search problem
          EJP
          Search through the users for what exactly?
          • 2. Re: Ldap search problem
            807422
            through their cn or email of uid
            • 3. Re: Ldap search problem
              EJP
              Please clarify. Vagueness is not enough.
              • 4. Re: Ldap search problem
                807422
                ok
                actually i want to perform a basic search using the user surname or uid or email and want to get all the details about that user
                in the ldap binding code i m connecting through a normal user in that OU and then i want to perform the search
                if u r still not clear ping me wht kind of info u want in regards of a basic search through LDAP
                • 5. Re: Ldap search problem
                  EJP
                  OK, so you need to execute an LDAP search (DirContext.search()) with a filter something like "(|(sn={0})(mail={1})(uid={2}))", with {surname, email, uid} as the corresponding arguments, with a SearchControl specifying subtree scope and "*" as the attributes to return.
                  • 6. Re: Ldap search problem
                    807422
                    Attributes matchAttrs = new BasicAttributes(true); // ignore attribute name case
                         matchAttrs.put(new BasicAttribute("sn",name));

                         NamingEnumeration answer = ctx.search("OU=mainorg,OU=suborg,dc=hello,dc=domain,dc=in ",matchAttrs);
                              formatResults(answer);
                         ctx.close();

                    i m doing this--in this formatresults is the simple function to print only
                    • 7. Re: Ldap search problem
                      EJP
                      i m doing this
                      Why? It's not what I recommended, and it's not what you said you needed to do. If you're not going to take any notice of what you're told here why post? and why should anybody bother answering?
                      --in this formatresults is the simple function to print only
                      You need to restate that in standard English, in case anybody is stilll interested.