inejge / ldap3

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

Attribute results pagination #85

Closed bck01215 closed 2 years ago

bck01215 commented 2 years ago

I am using ldap3 = { version = "0.10.5", features = ["gssapi"] } in my rust program.

I use an ldap query to get the members of a group,

let search_result = conn
        .search(
            &ou,
            Scope::Subtree,
            &format!("(&(objectClass=group)({}))", s_filter),
            vec!["member"],
        )
        .unwrap();

Instead of getting all members I get a hashmap like

{
        "member": [],
        "member;range=0-1499": [...]
}

Only the range has any information in it. The problem is, there are more members than just that range. No other ranges were returned.

I believe this should be default functionality as is with ptyhon's ldap3 package.

I'm new to rust so I'm struggling to find a way to implement this.

inejge commented 2 years ago

You can use the built-in PagedResults search adapter, see the search_adapted_paged_plus_sync.rs example. Adapted search gives you a generator-like struct from which you must retrieve entries sequentially. (They can be pushed to a vector or collected in one, although with thousands of results it's probably better to process them in a streaming manner.) Python's ldap3 has a dedicated search_paged() function, which this crate won't emulate.

bck01215 commented 2 years ago

This worked in the sense, I can change my ldap query to look for member of group as opposed to the member attribute of a group, but it didn't load all the attributes.

If I change the query to be

(&(objectClass=user)(memberOf={}))

I can get more than threshold of results because it's paged. but the attributes themselves are not paged and remain 1500. My original query which returns one group still returns one entry with only 1500 entries of the attribute

inejge commented 2 years ago

Ah, I misunderstood; you have an attribute limit, not an entry limit. I found this article (and, tbh, you could have, too.) Try to adapt their second solution (ranged searches) to your Rust code.

inejge commented 2 years ago

Closing for lack of feedback and being a usage issue.