[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ruby-ldap: bind authentication problem

Boris Glawe

7/2/2005 8:48:00 AM

Hi,

first of all: my problem is connected with ldap, but maybe you can help me
without knowing LDAP :-)

I'm trying to bind (authenticate) to our Active Directory Server (=LDAP Server)
with the ruby-ldap module ( http://sourceforge.net/projects/... ).

The bind method expects the user's distinguished name (kind of username) and a
password:

conn = LDAP::Conn.open("ldapserver.mydomain.com")
conn.simple_bind("cn=username,dc=mydomain,dc=com", "mysecret") {
# ...
}

When I hardcode the password as in the example above, the binding succeeds.
When I read the password from the keyboard, the binding does not succeed, though
it's the same:


password = $stdin.gets
password.chomp

conn = LDAP::Conn.open("ldapserver.mydomain.com")
conn.simple_bind("cn=username,dc=mydomain,dc=com", password) {
# ...
}


This code results in an "Invalid credentials Error" (which means something like
"username or password is wrong").

Can someone please explain me, what the difference between the two versions is?
Maybe there's something with the security level ($SAVE), that refuses to send
strings that origins from stdin!?

What else can be the reason?

thanks in advance

Boris
2 Answers

Boris Glawe

7/2/2005 12:52:00 PM

0

> When I read the password from the keyboard, the binding does not
> succeed, though
> it's the same:
>
>
> password = $stdin.gets
> password.chomp
>
> conn = LDAP::Conn.open("ldapserver.mydomain.com")
> conn.simple_bind("cn=username,dc=mydomain,dc=com", password) {
> # ...
> }
>

I found it out myself: The trailing newline was the problem.
password.chomp does not remove the newline, but returns another string without
the newline, which was send to nirvana in my case.

greets Boris

greg.kujawa

7/3/2005 1:06:00 AM

0

Boris Glawe wrote:

> I found it out myself: The trailing newline was the problem.
> password.chomp does not remove the newline, but returns another string without
> the newline, which was send to nirvana in my case.

That's why strings have the chomp! method which (rather than returning
a new string with the newline chopped off) actually changes the value
of the receiver so that the string itself no longer has the trailing
newline. Lots of other Ruby methods like this, such as gsub! for
example...