Announcement Announcement Module
Collapse
No announcement yet.
Ldap spring security config!! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ldap spring security config!!

    Hello,

    My gool is too use active directory setting in windows server 2008.
    When i connect via a java code : i can vue the attributes of ldap and i can manipulate the tree by using filter like this code :
    public static void main(String[] args) throws NamingException {
    Hashtable env = new Hashtable();
    String adminName = "CN=Administrator,CN=Users,DC=ldap,DC=com,DC=i nt";
    String adminPassword = "*****
    String ldapURL = "ldap://adresseIP:389/dc=ldap,dc=comar,dc=int";
    env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.j ndi.ldap.LdapCtxFactory");
    //set security credentials, note using simple cleartext authentication
    env.put(Context.SECURITY_AUTHENTICATION,"simple");
    env.put(Context.SECURITY_PRINCIPAL,adminName);
    env.put(Context.SECURITY_CREDENTIALS,adminPassword );

    //connect to my domain controller
    env.put(Context.PROVIDER_URL,ldapURL);


    DirContext ctx = new InitialDirContext(env);
    LinkedList list = new LinkedList();
    NamingEnumeration results = null;
    try {
    SearchControls controls = new SearchControls();
    controls.setSearchScope(SearchControls.SUBTREE_SCO PE);
    String filter = "(cn=test)";

    results = ctx.search("",filter, controls);

    while (results.hasMore()) {
    SearchResult searchResult = (SearchResult) results.next();
    Attributes attributes = searchResult.getAttributes();
    Attribute attr = attributes.get("distinguishedName");
    String dn = (String)attr.get(0);
    String[] tab=dn.split(",");
    System.out.println("dn ::"+dn); }
    } catch (NameNotFoundException e) {
    // The base context was not found.
    // Just clean up and exit.
    } catch (NamingException e) {
    throw new RuntimeException(e);
    } finally {
    if (results != null) {
    try {
    results.close();
    } catch (Exception e) {
    // Never mind this.
    }
    }
    if (ctx != null) {
    try {
    ctx.close();
    } catch (Exception e) {
    // Never mind this.
    }
    }
    }



    BUT
    when i configure withe same url, manager-dn and manger-password and i connect to my j2EE-flex application whithe the usertest)
    the connexion failed.


    I make the same thing , and i connect to an openldap setting on windows , he connect via application-security config :

    My config is :

    <s:ldap-server url="ldap://adrip:389/dc=ldap,dc=com,dc=int" manager-dn="CN=Administrator,CN=Users,DC=ldap,DC=com,DC=in t" manager-password="comar2010+"/>

    <s:ldap-authentication-provider
    user-search-base=""
    user-search-filter="cn={0}"
    group-search-filter="member={0}"
    group-role-attribute="cn"
    group-search-base=""
    role-prefix="none">

    </s:ldap-authentication-provider>



    Have you any Ideas ?

    Thank you
Working...
X