473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

java and ldap

Hi there,

i have a few problems accessing a ldap server with the java api JNDI.
I am able to get attributes with the following code:

env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.j ndi.ldap.LdapCtxFact
ory");
env.put(Context.PROVIDER_URL, "ldap://server:10389/");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "user=benutzer, ou=irgendwas,
o=nochwas, c=de");
env.put(Context.SECURITY_CREDENTIALS, "passwort");
try {

// Create the initial directory context
DirContext ctx = new InitialDirContext(env);
// Ask for all attributes of the object
Attributes attrs =
ctx.getAttributes("apc=einAPC,ou=irgendwas,o=nochw as,c=de");
// Find the ip adress and print
System.out.println("ip: " + attrs.get("IP").get());
} catch (NamingException e) {
System.err.println("Problem getting attribute:" + e);
}

But what to do, if i don't know the name of the APC?
I tried with searching, but i don't get any results:

try {
SearchControls ctls = new SearchControls();
ctls.setSearchScope(20);
// Specify the search filter to match
String filter = "(apc=*)";
DirContext ctx = new InitialDirContext(env);
// Search for objects using the filter
NamingEnumeration answer = ctx.search("", filter, ctls);
System.out.println("sind antworten
vorhanden?"+answer.hasMore()+"");
while (answer.hasMore()) {
SearchResult sr = (SearchResult)answer.next();
System.out.println(">>>" + sr.getName());
printAttrs(sr.getAttributes());
}
} catch (Exception err) {
System.out.println("fehler: " + err);
}

Structure of the directory:
c=de
|- o=nochwas, c=de
|-ou=irgendwas, o=nochwas, c=de
|-ou=irgendwas,
o=nochwas, c=de, apc=someAPC
ou=irgendwas,
o=nochwas, c=de, apc=anotherAPC

All apc's have an attribute apc.

Where is the problem?

Thx in advance
Bjoern


Jul 17 '05 #1
0 3576

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Arun | last post by:
Hi I am using the following Tomcat: 4.1.27-LE-jdk14 Apache: 2.0.47 Java : 1.4.2 Linux OS: 7.3 I am trying to configure LDAP authentication mechanism to my
0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
1
by: jslowery | last post by:
After much googling, I'm yet to see hint at the following topic. Has anyone ever worked on supporting ldap persistance of python objects? I'm a bit new to ldap, and I've noticed that there is a...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
0
by: DavidR | last post by:
I have some Java code that I need to mimic to have my ASP/C# web application (C# being the middle-tier) authenticate to a mainframe (running AIX) using LDAP. The Java code looks something like...
3
by: mbasil77 | last post by:
I'm trying to port a piece of Java LDAP conneciton code to DOTNET. I've done LDAP in DOTNET before, but I keep getting a very strange message. The Java code looks like: public static boolean...
0
by: crossroadsk | last post by:
I have a problem in configuring JNDI properties for LDAP server i created jndi.properties file in the current directory where i'm running a simple java code. jndi.properties file which i...
18
by: troywalker | last post by:
I am new to LDAP and Directory Services, and I have a project that requires me to authenticate users against a Sun Java System Directory Server in order to access the application. I have found...
0
by: rbukkara | last post by:
Hi, I have got the following error while trying to add a user in the LDAP Directory. javax.naming.NameNotFoundException: ; remaining name 'uid=vassila,ou=People,dc=cs,dc=uno,dc=edu' I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.