You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Stefan Seelmann (JIRA)" <ji...@apache.org> on 2017/03/13 21:08:41 UTC

[jira] [Commented] (DIRAPI-293) Unable to connect to an Active Directory server using 'userid@domain.com'.

    [ https://issues.apache.org/jira/browse/DIRAPI-293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15922943#comment-15922943 ] 

Stefan Seelmann commented on DIRAPI-293:
----------------------------------------

The simple API "LdapConnection.bind(name, password)" currently only allows valid DN as name.

But you have 2 options.

1) As you already configure the username and password in the LdapConnectionConfig you don't need to provide it again:
{noformat}
LdapConnectionConfig config = new LdapConnectionConfig();
config.setLdapHost( serverName);
config.setLdapPort( serverPort );
config.setName( userDN );
config.setCredentials( password );
LdapConnection connection = new LdapNetworkConnection(config);
connection.bind();
assertTrue( connection.isConnected() );
assertTrue( connection.isAuthenticated() );
{noformat}

This works because "LdapConnection.bind()" uses the low-level API, see next.

2) Use the low-level API directly:
{noformat}
    @Test
    public void testSimpleBindActiveDirectory() throws Exception
    {
        BindRequest bindRequest = new BindRequestImpl();
        bindRequest.setName( "userid@domain.com" );
        bindRequest.setCredentials( "secret" );
        BindResponse bindResponse = connection.bind( bindRequest );

        ResultCodeEnum resultCode = bindRequest.getResultResponse().getLdapResult().getResultCode();

        assertEquals( ResultCodeEnum.SUCCESS, resultCode );
        assertTrue( connection.isConnected() );
        assertTrue( connection.isAuthenticated() );
    }
{noformat}

> Unable to connect to an Active Directory server using 'userid@domain.com'. 
> ---------------------------------------------------------------------------
>
>                 Key: DIRAPI-293
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-293
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-RC2
>         Environment: Windows 7 Professional 64 bit
>            Reporter: Krishna Mohan
>
> Unable to connect to an Active Directory server using 'userid@domain.com'. For example Administrator@actiance.com
> Looks like Apache Directory LDAP API expects always DN as name for a bind request.
> Interestingly i was able to connect using Apache Directory Studio. What am I doing wrong in API code?
> Here is the sample code that i tried. Please check the exception stack trace below.
> LdapConnectionConfig config = new LdapConnectionConfig();
> config.setLdapHost( serverName);
> config.setLdapPort( serverPort );
> config.setName( userDN );
> config.setCredentials( password );
> LdapConnection connection = new LdapNetworkConnection(config);
> try {
> 	connection.bind(userDN, password);
> } catch (LdapException e) {
> 	// TODO Auto-generated catch block
> 	e.printStackTrace();
> }
> org.apache.directory.api.ldap.model.exception.LdapInvalidDnException: ERR_04202 A value is missing on some RDN
> 	at org.apache.directory.api.ldap.model.name.Dn.<init>(Dn.java:282)
> 	at org.apache.directory.ldap.client.api.AbstractLdapConnection.bind(AbstractLdapConnection.java:112)
> 	at com.actiance.platform.ldap.LDAPClient.<init>(LDAPClient.java:86)



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)