From: Bedo Sandor Date: 2004-01-06T00:48:38+09:00 Subject: Re: libldap-ruby and \000 On Mon, Jan 05, 2004 at 11:00:46PM +0900, Takaaki Tateishi wrote: > > How can I add binary data containing the \0 character? > > Could you try the following code? > > entry = [ > LDAP.mod(LDAP::LDAP_MOD_ADD, 'objectClass', [ 'top', 'strongAuthenticationUser', 'person' ]), > LDAP.mod(LDAP::LDAP_MOD_ADD, 'cn', [ "test" ]), > LDAP.mod(LDAP::LDAP_MOD_ADD, 'sn', [ "test" ]), > LDAP.mod(LDAP::LDAP_MOD_ADD | LDAP::LDAP_MOD_BVALUES, 'userCertificate;binary', [ binaryData ]) > ] Thank You, this works. But I think hashes are more distinct than modify chains... Is this conversion a wrong idea? class Hash def to_ldapmodify tmp = [] self.each_key { |attr| next if attr == 'dn' values = self[attr].to_a mod = LDAP::LDAP_MOD_ADD mod |= LDAP::LDAP_MOD_BVALUES if values.find { |e| e =~ /\000/ } tmp << LDAP.mod(mod, attr, values) } return tmp end end -- bSanyI