Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to represent integer attributes? #27

Closed
nitnelave opened this issue Jun 17, 2023 · 4 comments
Closed

How to represent integer attributes? #27

nitnelave opened this issue Jun 17, 2023 · 4 comments

Comments

@nitnelave
Copy link
Collaborator

Let's say I want to create a LdapPartialAttribute with a numerical value.

LdapPartialAttribute {
  atype: "uid".to_owned(),
  vals: vec![123],
}

How do I represent that 123 as bytes? Is there a special encoding necessary? Or do I convert it to i64 then do a cast to 8 raw bytes?

@Firstyear
Copy link
Member

There are two options: https://www.rfc-editor.org/rfc/rfc4517#section-3.3.16 You can make it a integer here which is the output of i64 to_string() and then parsed.

Or you can use https://www.rfc-editor.org/rfc/rfc4517#section-3.3.25 and convert to a byte-array stored as an octet string, and then back again.

Generally if this was a uidNumber such as in posix, you would use the former integer-string method.

@nitnelave
Copy link
Collaborator Author

I'm looking to be as compatible as possible with common ldap tools, like ldapsearch. Would it make sense to add a int-to-byte-array conversion function in this repo? It would facilitate clients' life, I guess. Or is the "compatible" option the string representation?

@Firstyear
Copy link
Member

compatible is the string representation from my experience.

@nitnelave
Copy link
Collaborator Author

Perfect, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants