on 10-16-2007 1:17 PM
Hi Experts
I am developing a webdynpro application that would contact the LDAP server of my company for the login credentials can u please help out in this issue in need the webdynpro code for this connection
Regards
Noel
Hi! Noel,
there are two ways to get connected to LDAP server from your webDynpro application.
1.By Using UME API(right choice in case your portal is connected to the LDAP through UME)
2.By setting some properties of LDAP server in your webdynpro appl.
code sample for first one:--
// Input for search
String input= "sahu";
IUserFactory userFactory = UMFactory.getUserFactory();
IUserSearchFilter searchFilter = userFactory.getUserSearchFilter();
//setting search attributes
searchFilter.setLastname(input,ISearchAttribute.LIKE_OPERATOR,false);
//start search
ISearchResult searchResult = userFactory.searchUsers(searchFilter);
// iterate over search result
while(searchResult.hasNext()) {
//do something
String userID= (String) searchResult.next();
IUser user= userFactory.getUser(userID);
String email= user.getEmail();
//...
}
Code sample for Second One:--
// Connect to server
Hashtable env = new Hashtable();
env.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
env.put("java.naming.provider.url", "ldap://<server_name>");
env.put("java.naming.security.authentication", "simple");
env.put("java.naming.security.principal", "<domain>
<user_name>");
env.put("java.naming.security.credentials", "<password>");
DirContext ctx = new InitialDirContext(env);
// Create search controls
SearchControls controls = new SearchControls();
controls.setCountLimit(0);
controls.setTimeLimit(0);
controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
// Create filter
String filter = "(sAMAccountName= *)"
// Run search
NamingEnumeration results = ctx.search("OU=OUs,DC=mycomp,DC=com", filter, controls);
i got this example from one SDN blog only but forget the link.
regards,
mithileshwar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.