You are viewing a plain text version of this content. The canonical link for it is here.
Posted to api@directory.apache.org by Emmanuel Lecharny <el...@gmail.com> on 2010/02/11 12:03:44 UTC
Connection : Simple Bind operation
Hi,
I just checked the way all the API handle the simple Bind() operation.
Here is a sum up :
ADS :
-----
see later...
jLdap :
-------
synchronous :
* bind(int, String, byte[])
* bind(int, String, byte[], LDAPConstraints)
asynchronous :
* bind(int, String, byte[], LDAPResponseQueue)
* bind(int, String, byte[], LDAPResponseQueue, LDAPConstraints)
LDAPConstraints will contain the controls.
LDAPResponseQueue is used for asynchronous operation
JNDI :
------
JNDI Bind operation is totally different. It's semantically another
beast. A LDAP Bind on JNDI is done through the creation of a Context,
and the user/credentials are passed in a hashtable. We don't want to go
there ...
ODS :
-----
synchronous :
* Connection.bind(BindRequest)
* Connection.bind(String, String)
asynchronous :
* LdapConnection.bind(BindRequest, ResultHandler<? super BindResult>)
Beside the fact that it's not obvious that LdapConnection class means
'asynchronous', a password may be a byte[] so we won't be able to easily
bind in this case (a user will have to create a BindRequest). Anonymous
bind needs to pass null values to the bind operation.
UID :
-----
synchronous :
* bind(BindRequest)
* bind(String, String)
No asynchronous bind.
Summary :
---------
This is really an area where the APIs differ a lot. If we come back to
the RFC, a Simple Bind operation has 3 valid forms and one invalid :
user = null, password = null : anonymous bind
user != null, password = null : unauthenticated bind
user = null, password != null : invalid
user != null, password != null : simple authentication
In any case, the password is an Octet String, ie a byte[]. The user is
always a DN when doing a simple bind.
Some last consideration : if we are to support asynchronous operations,
then we need to make this explicit.
I suggest we keep it simple from the user pov, considering that :
- users will mainly do synchronous operations
- anonymous bind must be easy to code
- we want to make it explicit that the async mode is used
- and we don't want zillion of methods.
So every method bind(...) will have a equivalent async method
bindAsync(), the anonymous bind will be a bind() method without
parameters, the password can be either a String or a byte[], and the
user can be either a String or a DN :
synchronous :
* bind() anonymous bind
* bind( String userDN, String password ): simple bind (if the password
is null, this will be the unauthenticated bind)
* bind( String userDN, String password )
* bind( DN userDN, String password )
* bind( String userDN, byte[] password )
* bind( DN userDN, byte[] password )
* bind( BindRequest )
asynchronous :
* bindAsync() anonymous bind
* bindAsync( String userDN, String password ): simple bind (if the
password is null, this will be the unauthenticated bind)
* bindAsync( String userDN, String password )
* bindAsync( DN userDN, String password )
* bindAsync( String userDN, byte[] password )
* bindAsync( DN userDN, byte[] password )
* bindAsync( BindRequest )
This is currently what we have in ADS, not because it's better, but
because we have redesigned the API after having written this mail (the
previous API was, hmmm. ok. don't ask ;)
thoughts ?
--
Regards,
Cordialement,
Emmanuel Lécharny
www.nextury.com
Re: Connection : Simple Bind operation
Posted by Kiran Ayyagari <ay...@gmail.com>.
+1
thanks Emmanuel
Kiran Ayyagari
Emmanuel Lecharny wrote:
> Hi,
>
> I just checked the way all the API handle the simple Bind() operation.
> Here is a sum up :
>
> ADS :
> -----
> see later...
>
> jLdap :
> -------
> synchronous :
> * bind(int, String, byte[])
> * bind(int, String, byte[], LDAPConstraints)
>
> asynchronous :
> * bind(int, String, byte[], LDAPResponseQueue)
> * bind(int, String, byte[], LDAPResponseQueue, LDAPConstraints)
>
> LDAPConstraints will contain the controls.
> LDAPResponseQueue is used for asynchronous operation
>
>
> JNDI :
> ------
>
> JNDI Bind operation is totally different. It's semantically another
> beast. A LDAP Bind on JNDI is done through the creation of a Context,
> and the user/credentials are passed in a hashtable. We don't want to go
> there ...
>
> ODS :
> -----
> synchronous :
> * Connection.bind(BindRequest)
> * Connection.bind(String, String)
>
> asynchronous :
> * LdapConnection.bind(BindRequest, ResultHandler<? super BindResult>)
>
> Beside the fact that it's not obvious that LdapConnection class means
> 'asynchronous', a password may be a byte[] so we won't be able to easily
> bind in this case (a user will have to create a BindRequest). Anonymous
> bind needs to pass null values to the bind operation.
>
> UID :
> -----
> synchronous :
> * bind(BindRequest)
> * bind(String, String)
>
> No asynchronous bind.
>
> Summary :
> ---------
> This is really an area where the APIs differ a lot. If we come back to
> the RFC, a Simple Bind operation has 3 valid forms and one invalid :
> user = null, password = null : anonymous bind
> user != null, password = null : unauthenticated bind
> user = null, password != null : invalid
> user != null, password != null : simple authentication
>
> In any case, the password is an Octet String, ie a byte[]. The user is
> always a DN when doing a simple bind.
>
> Some last consideration : if we are to support asynchronous operations,
> then we need to make this explicit.
>
> I suggest we keep it simple from the user pov, considering that :
> - users will mainly do synchronous operations
> - anonymous bind must be easy to code
> - we want to make it explicit that the async mode is used
> - and we don't want zillion of methods.
>
> So every method bind(...) will have a equivalent async method
> bindAsync(), the anonymous bind will be a bind() method without
> parameters, the password can be either a String or a byte[], and the
> user can be either a String or a DN :
>
> synchronous :
> * bind() anonymous bind
> * bind( String userDN, String password ): simple bind (if the password
> is null, this will be the unauthenticated bind)
> * bind( String userDN, String password )
> * bind( DN userDN, String password )
> * bind( String userDN, byte[] password )
> * bind( DN userDN, byte[] password )
> * bind( BindRequest )
>
> asynchronous :
> * bindAsync() anonymous bind
> * bindAsync( String userDN, String password ): simple bind (if the
> password is null, this will be the unauthenticated bind)
> * bindAsync( String userDN, String password )
> * bindAsync( DN userDN, String password )
> * bindAsync( String userDN, byte[] password )
> * bindAsync( DN userDN, byte[] password )
> * bindAsync( BindRequest )
>
> This is currently what we have in ADS, not because it's better, but
> because we have redesigned the API after having written this mail (the
> previous API was, hmmm. ok. don't ask ;)
>
> thoughts ?
>
Re: Connection : Simple Bind operation
Posted by Emmanuel Lecharny <el...@gmail.com>.
On 2/11/10 7:59 PM, Stefan Seelmann wrote:
> Emmanuel Lecharny wrote:
>>
>> In any case, the password is an Octet String, ie a byte[]. The user
>> is always a DN when doing a simple bind.
>
> At least to Active Directory you can bind with a username like
> user@DOMAIN. So the API should allow a non-DN user.
Bloody M$ !!! Yeah, you are right. Then the bind( String, String/byte[])
should not check that the user is a valid DN.
>
>> Some last consideration : if we are to support asynchronous
>> operations, then we need to make this explicit.
>>
>> I suggest we keep it simple from the user pov, considering that :
>> - users will mainly do synchronous operations
>> - anonymous bind must be easy to code
>
> what if the user forgets to call a "bind" method but just calls
> another operation? Should we check that at the client? Should we do an
> implicit anyonymous bind?
This is perfectly valid. You can do a straight search() without having
done a previous bind() : the server should assume that it's an anonymous
bind.
>
>> - we want to make it explicit that the async mode is used
>> - and we don't want zillion of methods.
>>
>> So every method bind(...) will have a equivalent async method
>> bindAsync(), the anonymous bind will be a bind() method without
>> parameters, the password can be either a String or a byte[], and the
>> user can be either a String or a DN :
>>
>> synchronous :
>> * bind() anonymous bind
>> * bind( String userDN, String password ): simple bind (if the
>> password is null, this will be the unauthenticated bind)
>> * bind( String userDN, String password )
>> * bind( DN userDN, String password )
>> * bind( String userDN, byte[] password )
>> * bind( DN userDN, byte[] password )
>> * bind( BindRequest )
>
> I'm not sure if we really need the variants with a byte[] password.
> The user has to type in the password somewhere, so in most cases the
> password is a string. If the user really wants to do it s/he must use
> a BindRequest.
That's an option, sure. In some case, the password can also be a binary
value the user won't type (like with fingerprints, for instance). You
have so many cool devices out there those days !!!
>
>> asynchronous :
>> * bindAsync() anonymous bind
>> * bindAsync( String userDN, String password ): simple bind (if the
>> password is null, this will be the unauthenticated bind)
>> * bindAsync( String userDN, String password )
>> * bindAsync( DN userDN, String password )
>> * bindAsync( String userDN, byte[] password )
>> * bindAsync( DN userDN, byte[] password )
>> * bindAsync( BindRequest )
>
> Is there some handle returned by the async methods?
Yes, you get back a Future.
--
Regards,
Cordialement,
Emmanuel Lécharny
www.nextury.com
Re: Connection : Simple Bind operation
Posted by Stefan Seelmann <se...@apache.org>.
Emmanuel Lecharny wrote:
>
> In any case, the password is an Octet String, ie a byte[]. The user is
> always a DN when doing a simple bind.
At least to Active Directory you can bind with a username like
user@DOMAIN. So the API should allow a non-DN user.
> Some last consideration : if we are to support asynchronous operations,
> then we need to make this explicit.
>
> I suggest we keep it simple from the user pov, considering that :
> - users will mainly do synchronous operations
> - anonymous bind must be easy to code
what if the user forgets to call a "bind" method but just calls another
operation? Should we check that at the client? Should we do an implicit
anyonymous bind?
> - we want to make it explicit that the async mode is used
> - and we don't want zillion of methods.
>
> So every method bind(...) will have a equivalent async method
> bindAsync(), the anonymous bind will be a bind() method without
> parameters, the password can be either a String or a byte[], and the
> user can be either a String or a DN :
>
> synchronous :
> * bind() anonymous bind
> * bind( String userDN, String password ): simple bind (if the password
> is null, this will be the unauthenticated bind)
> * bind( String userDN, String password )
> * bind( DN userDN, String password )
> * bind( String userDN, byte[] password )
> * bind( DN userDN, byte[] password )
> * bind( BindRequest )
I'm not sure if we really need the variants with a byte[] password. The
user has to type in the password somewhere, so in most cases the
password is a string. If the user really wants to do it s/he must use a
BindRequest.
> asynchronous :
> * bindAsync() anonymous bind
> * bindAsync( String userDN, String password ): simple bind (if the
> password is null, this will be the unauthenticated bind)
> * bindAsync( String userDN, String password )
> * bindAsync( DN userDN, String password )
> * bindAsync( String userDN, byte[] password )
> * bindAsync( DN userDN, byte[] password )
> * bindAsync( BindRequest )
Is there some handle returned by the async methods?
Kind Regards,
Stefan