Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

LDAP NamingException while getting attributes

Thread view: 
Sharif Islam - 17 Sep 2007 21:09 GMT
javax.naming.NamingException: [LDAP: error code 1 - 000020D6: SvcErr:
DSID-031006CC, problem 5012 (DIR_ERROR), data 0

I am able to bind fine with my active directory server, but when I try
to get any attributeu, I get the above error. I need to get the
givenName and sn. I think I am proving the wrong context?

CODE:
String ldap_search_context ="OU=users,DC=mycompany,DC=com";
String attlist[] = {"sn"}
 try
              {
             DirContext ctx = new InitialDirContext(env);
          NamingEnumeration answer = null;
          System.out.println("Connection toString: " + ctx.toString());
          Attributes matchAttrs = new BasicAttributes(true);
          matchAttrs.put(new BasicAttribute("cn","username"));
         System.out.println(matchAttrs.toString());
         answer = ctx.search(ldap_search_context, matchAttrs,attlist);
                        while(answer.hasMore())
                       {
                     SearchResult sr = (SearchResult)answer.next();
                    System.out.println(">>>" + sr.getName());

                        }

                }
Roedy Green - 18 Sep 2007 00:07 GMT
On Mon, 17 Sep 2007 15:09:11 -0500, Sharif Islam
<mislam@npspam.uiuc.edu> wrote, quoted or indirectly quoted someone
who said :

>  DirContext ctx = new InitialDirContext(env);

You don't show your definition of env. Here is the sort of thing you
need:

   Hashtable<String, String> env = new Hashtable<String, String>();
   env.put( "java.naming.factory.initial",
                "com.sun.jndi.dns.DnsContextFactory" );
       DirContext ictx = new InitialDirContext( env );

Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Nigel Wade - 18 Sep 2007 09:51 GMT
> javax.naming.NamingException: [LDAP: error code 1 - 000020D6: SvcErr:
> DSID-031006CC, problem 5012 (DIR_ERROR), data 0
[quoted text clipped - 13 lines]
>            Attributes matchAttrs = new BasicAttributes(true);
>            matchAttrs.put(new BasicAttribute("cn","username"));

The BasicAttribute you want to match needs to be a valid directory search
string.

E.g.
new BasicAttribute("(cn=username)")

Signature

Nigel Wade, System Administrator, Space Plasma Physics Group,
           University of Leicester, Leicester, LE1 7RH, UK
E-mail :    nmw@ion.le.ac.uk
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.