inejge / ldap3

A pure-Rust LDAP library using the Tokio stack
Apache License 2.0
220 stars 38 forks source link

Modifications with values as `Vec<u8>` #20

Closed sindreij closed 6 years ago

sindreij commented 6 years ago

Hello. Great to see a pure rust LDAP library.

I have an issue. I want to set a password in Active Directory, and for that I need to send the password encoded using utf-16 [1]. As far as I can tell, that is not possible using this library, since modify() takes a AsRef<str>, and a str only can have utf-8. So I need some way of inputing a Vec<u8>. Is it maybe possible to encode the Vec<u8> as a String?

If indeed this needs a code change, do you want me to create a PR?

inejge commented 6 years ago

Right, Modify (and Add) don't allow binary values. Try 7545f79385f415e1847088cf6a2588b8ffda78b6; it just uses AsRef<[u8]> instead of AsRef<str>, which shouldn't break anything else. If that works, I'll change the Add operation in the same way.

sindreij commented 6 years ago

Thanks, I think that will work. I am in the process now of changing my code from using libldap to this library, and when I get it to work, I will try that branch.

sindreij commented 6 years ago

I said modify, but actually it was add() I used binary values for. I tested my code with your changes to support [u8] and it works great!