Forum: Ruby net::ldap - add_attribute

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fecb400607442b54b6df80b4018240f9?d=identicon&s=25 Rcmn 73 (rcmn)
on 2007-02-02 22:22
i'm trying to add a workstation "monnomdemachine" to a group "mygroup"

but i get "#<OpenStruct message="Unwilling to perform", code=53>"


require 'net/ldap'

# look up Machine to ProdWindowsXPWorkstations
 ldap = Net::LDAP.new :host => '11111111',
      :port => 389,
      :auth => {
            :method => :simple,
            :username =>
"cn=user,ou=ou0,ou=ou1,ou=ou3,dc=dc,dc=dc1,dc=net",
            :password => "pass"
      }

 filter = Net::LDAP::Filter.eq( "cn", "monnomdemachine" )
 treebase = "dc=dc,dc=dc1,dc=net"

 ldap.search( :base => treebase, :filter => filter ) do |entry|
   $dnwks = "DN: #{entry.dn}"
   end

    gr = "CN=mygoupe,OU=uu2,OU=uu1,OU=uu,dc=dc,dc=dc1,dc=net"
 ldap.add_attribute gr, :member, $dnwks

p ldap.get_operation_result
481b8eedcc884289756246e12d1869c1?d=identicon&s=25 Francis Cianfrocca (blackhedd)
on 2007-02-03 00:43
(Received via mailing list)
On 2/2/07, Rcmn 73 <rcmn73@gmail.com> wrote:
>       :port => 389,
> ldap.search( :base => treebase, :filter => filter ) do |entry|
>
>

Looks like you gave the parameters to Net::LDAP#add_attribute in the
wrong
order.

By the way, you don't have to give a block to Net::LDAP#search if you
prefer
not to. It will return an array of the returned objects.
Fecb400607442b54b6df80b4018240f9?d=identicon&s=25 Rcmn 73 (rcmn)
on 2007-02-03 01:40
> Looks like you gave the parameters to Net::LDAP#add_attribute in the
> wrong
> order.
>

are we talking about
> ldap.add_attribute gr, :member, $dnwks

or

> ldap.search( :base => treebase, :filter => filter ) do |entry|

search seems to work fine since i'm able to return entry but i have
trouble add_attribute .i followed the rdoc but maybe i don't use it
properly.
481b8eedcc884289756246e12d1869c1?d=identicon&s=25 Francis Cianfrocca (blackhedd)
on 2007-02-03 01:47
(Received via mailing list)
On 2/2/07, Rcmn 73 <rcmn73@gmail.com> wrote:
>
>
>  are we talking about
> > ldap.add_attribute gr, :member, $dnwks



Yes. Re-read the rdoc. The DN which specifies the entry to which you are
adding the attribute is the first parameter.
Fecb400607442b54b6df80b4018240f9?d=identicon&s=25 Rcmn 73 (rcmn)
on 2007-02-03 21:20
Francis Cianfrocca wrote:
> On 2/2/07, Rcmn 73 <rcmn73@gmail.com> wrote:
>>
>>
>>  are we talking about
>> > ldap.add_attribute gr, :member, $dnwks
>
>
>
> Yes. Re-read the rdoc. The DN which specifies the entry to which you are
> adding the attribute is the first parameter.

i think i'm using it properly.
> ldap.add_attribute gr, :member, $dnwks

"gr" is the group to which i want to add an entry.
":member" is the attribute.So i will add the member $dnwks to gr.
"$dnwks" is the object i want to add.

also it tried various combination but it get worst.
Fecb400607442b54b6df80b4018240f9?d=identicon&s=25 Rcmn 73 (rcmn)
on 2007-02-05 17:45
I finally found my mistake and fixed it that way.
thank you for the help.

require 'net/ldap'

# look up Machine to ProdWindowsXPWorkstations
 ldap = Net::LDAP.new :host => '11111111',
      :port => 389,
      :auth => {
            :method => :simple,
            :username =>
"cn=user,ou=ou0,ou=ou1,ou=ou3,dc=dc,dc=dc1,dc=net",
            :password => "pass"
      }

 filter = Net::LDAP::Filter.eq( "cn", "monnomdemachine" )
 treebase = "dc=dc,dc=dc1,dc=net"

 ldap.search( :base => treebase, :filter => filter ) do |entry|
   dnwks = "DN: #{entry.dn}"


    dn = "CN=mygoupe,OU=uu2,OU=uu1,OU=uu,dc=dc,dc=dc1,dc=net"
 ldap.add_attribute dn, :member, dnwks
end
p ldap.get_operation_result
481b8eedcc884289756246e12d1869c1?d=identicon&s=25 Francis Cianfrocca (blackhedd)
on 2007-02-05 20:22
(Received via mailing list)
On 2/5/07, Rcmn 73 <rcmn73@gmail.com> wrote:
>             :method => :simple,
>
>
>     dn = "CN=mygoupe,OU=uu2,OU=uu1,OU=uu,dc=dc,dc=dc1,dc=net"
> ldap.add_attribute dn, :member, dnwks
> end
> p ldap.get_operation_result
>
> --
> Posted via http://www.ruby-forum.com/.
>
>

Ah. Sounds like the problem was a schema violation all along, then. That
also is consistent with a 53 error code.
Fecb400607442b54b6df80b4018240f9?d=identicon&s=25 Rcmn 73 (rcmn)
on 2007-02-05 20:43
Francis Cianfrocca wrote:
> On 2/5/07, Rcmn 73 <rcmn73@gmail.com> wrote:
>>             :method => :simple,
>>
>>
>>     dn = "CN=mygoupe,OU=uu2,OU=uu1,OU=uu,dc=dc,dc=dc1,dc=net"
>> ldap.add_attribute dn, :member, dnwks
>> end
>> p ldap.get_operation_result
>>
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>>
>
> Ah. Sounds like the problem was a schema violation all along, then. That
> also is consistent with a 53 error code.

yes it was.thx.

I had 2 other questions the first one is related to this post
http://www.ruby-forum.com/topic/82437#144516 and i was wondering if
other people asked for it and if so ;do you think it might be supported?
if not what would be a good work around ?
Fecb400607442b54b6df80b4018240f9?d=identicon&s=25 Rcmn 73 (rcmn)
on 2007-02-05 21:00
Rcmn 73 wrote:
> Francis Cianfrocca wrote:
>> On 2/5/07, Rcmn 73 <rcmn73@gmail.com> wrote:
>>            :method => :simple,

> I had 2 other questions the first one is related to this post
> http://www.ruby-forum.com/topic/82437#144516 and i was wondering if
> other people asked for it and if so ;do you think it might be supported?
> if not what would be a good work around ?

 and i forgot my 2nd question.would ldap.modify be faster than
ldap.add_attribute ?
481b8eedcc884289756246e12d1869c1?d=identicon&s=25 Francis Cianfrocca (blackhedd)
on 2007-02-05 21:11
(Received via mailing list)
On 2/5/07, Rcmn 73 <rcmn73@gmail.com> wrote:
>
> and i forgot my 2nd question.would ldap.modify be faster than
> ldap.add_attribute ?
>
> --
> Posted via http://www.ruby-forum.com/.
>
>

#add_attribute and #modify are essentially the same protocol on the
wire. I
doubt the client-side code for one is much faster than the other. If it
were, the network latency would probably be far more than the difference
anyway.
481b8eedcc884289756246e12d1869c1?d=identicon&s=25 Francis Cianfrocca (blackhedd)
on 2007-02-05 21:15
(Received via mailing list)
On 2/5/07, Rcmn 73 <rcmn73@gmail.com> wrote:
>
> Rcmn 73 wrote:
> > Francis Cianfrocca wrote:
> >> On 2/5/07, Rcmn 73 <rcmn73@gmail.com> wrote:
> >>            :method => :simple,
>
> > I had 2 other questions the first one is related to this post
> > http://www.ruby-forum.com/topic/82437#144516 and i was wondering if
> > other people asked for it and if so ;do you think it might be supported?
> > if not what would be a good work around ?



I have to confess that I 'm still not clear on what you want to do in
regard
to the password storage problem. Net::LDAP already has the ability to
take a
Ruby block in place of a String password in the places where a password
is
required (Net::LDAP#open, Net::LDAP#new). Check that out and see if you
can
use it. If not, then I'll need a more clearly-stated feature request.
This topic is locked and can not be replied to.