LDAP as data source for authentication

  1. Enter the URL of your LDAP server at Provider URL.

  2. Enter the appropriate parameters for your LDAP server in Optional Settings.

  3. Click Finish.

Options:

  • *Optional Settings

  • Search Base - Defines where in the directory the LDAP search starts.

    • CN - commonName.

    • L - localityName.

    • ST - stateOrProvinceName.

    • O - organizationName.

    • OU - organizationalUnitName.

    • C - countryName.

    • STREET - streetAddress.

    • DC - domainComponent.

    • UID - userid.

  • Suffix - Root, topmost data object of an LDAP data structure.

  • Scurity Protocol - Optional security protocol (e.g. SASL, SSL).

    • Security Authentication - Standard Security Protocol (none / simple / SASL)

  • Test Connection - Own access data. Only necessary to test the connection.

Result:

Project Management > Business Objects - The class ExampleAuthenticationProvider.java is generated.

+

package com.company.example.business;

import javax.naming.directory.DirContext;

import com.xdev.security.authentication.Authenticator;
import com.xdev.security.authentication.AuthenticatorProvider;
import com.xdev.security.authentication.CredentialsUsernamePassword;
import com.xdev.security.authentication.ldap.LDAPAuthenticator;
import com.xdev.security.authentication.ldap.LDAPConfiguration.LDAPConfigurationBuilder;

public class MyAuthenticationProvider implements AuthenticatorProvider<CredentialsUsernamePassword, DirContext> {
    private static MyAuthenticationProvider INSTANCE;

    public static MyAuthenticationProvider getInstance() {
        if (INSTANCE == null) {
            INSTANCE = new MyAuthenticationProvider();
        }

        return INSTANCE;
    }

    private LDAPAuthenticator authenticator;

    private MyAuthenticationProvider() {
    }

    @Override
    public Authenticator<CredentialsUsernamePassword, DirContext> provideAuthenticator() {
        if (this.authenticator == null) {
            this.authenticator = new LDAPAuthenticator(
                    new LDAPConfigurationBuilder("ldap://192.168.90.7:389/dc=yourDomainComponent,dc=local")
                            .searchBase("OU=SBSUsers,OU=Users,OU=MyBusiness").suffix("@YOURDOMAIN.LOCAL")
                            .securityAuthentication("simple").build());
        }

        return this.authenticator;
    }
}