net::ldap - add_attribute

R

Rcmn 73

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
 
R

Rcmn 73

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.
 
R

Rcmn 73

Francis said:
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.
 
R

Rcmn 73

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
 
R

Rcmn 73

Francis said:
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 ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top