Pharo & LDAP

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Pharo & LDAP

Olivier Auverlot
Hi,

For a project of REST services with Pharo and Seaside, I need to send
requests to an LDAP server. I found a project named LDAPlayer on
squeaksource.

Now, I can create a connection and do a request to the LDAP server.

But... my problem is to read an attribute in the result. In the
LDAPSearchResultEntry object, the method to get a value is :

attrAt: aKey
     | selected |
     selected := attrs at: (aKey asByteArray) ifAbsent: [ ^ nil ].
     ^ selected first asString.

The problem seems to be on the third line with the use of the
asByteArray method. Why used this method ?

For my tests, I remplaced it with :

selected := attrs at: aKey ifAbsent: [ ^ nil ].

And now, it's ok but I don't know if my modification could introduce
others problems.

What do you think about that ? Someone has used LDAPlayer with Pharo ?

Best regards

Olivier ;-)

www.auverlot.fr

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Pharo & LDAP

Schwab,Wilhelm K
I have used LDAPlayer with good results.  There are small problems on Pharo - a DNU over #and:and: IIRC.  As the self-appointed silent failure pedant, I would like to suggest a change to your code.  Please try/consider (untested code):

attrAt: aKey ifNone:ifNone
     | selected |
     selected := attrs at:aKey ifPresent:[ :value | aKey asByteArray ] ifAbsent: [ ^ifNone value ].
     ^ selected first asString.

That way, one can know whether the item was missing, treating that condition as an error or ignoring it as appears to work in your case.  My images are littered with #asByteArray methods, which complicates spotting what that might be doing.  The change above (hopefully??) preserves the original behavior when the attribute is present; at least that was my goal.


________________________________________
From: [hidden email] [[hidden email]] On Behalf Of Olivier Auverlot [[hidden email]]
Sent: Wednesday, February 16, 2011 8:41 AM
To: [hidden email]
Subject: [Pharo-project] Pharo & LDAP

Hi,

For a project of REST services with Pharo and Seaside, I need to send
requests to an LDAP server. I found a project named LDAPlayer on
squeaksource.

Now, I can create a connection and do a request to the LDAP server.

But... my problem is to read an attribute in the result. In the
LDAPSearchResultEntry object, the method to get a value is :

attrAt: aKey
     | selected |
     selected := attrs at: (aKey asByteArray) ifAbsent: [ ^ nil ].
     ^ selected first asString.

The problem seems to be on the third line with the use of the
asByteArray method. Why used this method ?

For my tests, I remplaced it with :

selected := attrs at: aKey ifAbsent: [ ^ nil ].

And now, it's ok but I don't know if my modification could introduce
others problems.

What do you think about that ? Someone has used LDAPlayer with Pharo ?

Best regards

Olivier ;-)

www.auverlot.fr


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Pharo & LDAP

Stéphane Ducasse
In reply to this post by Olivier Auverlot
did you check what you got in attrs?
Because may be the code is simply old and require fixes.

Stef

> Hi,
>
> For a project of REST services with Pharo and Seaside, I need to send requests to an LDAP server. I found a project named LDAPlayer on squeaksource.
>
> Now, I can create a connection and do a request to the LDAP server.
>
> But... my problem is to read an attribute in the result. In the LDAPSearchResultEntry object, the method to get a value is :
>
> attrAt: aKey
>    | selected |
>    selected := attrs at: (aKey asByteArray) ifAbsent: [ ^ nil ].
>    ^ selected first asString.
>
> The problem seems to be on the third line with the use of the asByteArray method. Why used this method ?
>
> For my tests, I remplaced it with :
>
> selected := attrs at: aKey ifAbsent: [ ^ nil ].
>
> And now, it's ok but I don't know if my modification could introduce others problems.
>
> What do you think about that ? Someone has used LDAPlayer with Pharo ?
>
> Best regards
>
> Olivier ;-)
>
> www.auverlot.fr
>


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Pharo & LDAP

Olivier Auverlot
Le 16/02/11 20:59, Stéphane Ducasse a écrit :
> did you check what you got in attrs?
This is a dictionnary... this is why that i ask me the utility of the
method asByteArray.
> Because may be the code is simply old and require fixes.
yes. it's possible. I already changed the code because it contains the
deprecated method or:or:

I will take time in the next day to evaluate LDAPlayer. I think it is
critical for Pharo to have an LDAP network protocol. Many enterprises
use it for user identification and data storage.

Olivier ;-)

www.auverlot.fr

> Stef
>
>> Hi,
>>
>> For a project of REST services with Pharo and Seaside, I need to send requests to an LDAP server. I found a project named LDAPlayer on squeaksource.
>>
>> Now, I can create a connection and do a request to the LDAP server.
>>
>> But... my problem is to read an attribute in the result. In the LDAPSearchResultEntry object, the method to get a value is :
>>
>> attrAt: aKey
>>     | selected |
>>     selected := attrs at: (aKey asByteArray) ifAbsent: [ ^ nil ].
>>     ^ selected first asString.
>>
>> The problem seems to be on the third line with the use of the asByteArray method. Why used this method ?
>>
>> For my tests, I remplaced it with :
>>
>> selected := attrs at: aKey ifAbsent: [ ^ nil ].
>>
>> And now, it's ok but I don't know if my modification could introduce others problems.
>>
>> What do you think about that ? Someone has used LDAPlayer with Pharo ?
>>
>> Best regards
>>
>> Olivier ;-)
>>
>> www.auverlot.fr
>>
>


Loading...