none
PageResultResponseControl not returning cookie RRS feed

  • Question

  • Hi,

    I am trying to get the deleted entries from AD using ShowDeletedControl and applying paging with PageResultRequestControl with a page size of 900.

    When I delete 1000 or more users, from AD and try to fetch it, after fetching the first 900 users, it does not give me the cookie for the next request to be sent.

    In the response, the cookie received is of size 0, resulting in fetching only 900 users deleted.

    ShowDeletedControl delControl = new ShowDeletedControl();
    PageResultRequestControl pageControl = new PageResultRequestControl(900);
    
    string filter = "(&(isDeleted=TRUE)(usnchanged>=" + usnchanged_old + ")(usnchanged<=" + usnchanged_new + "))";
    
    SearchRequest request = new SearchRequest(
                                        distinguishedName: searchBase,
                                        ldapFilter: filter,
                                        searchScope: SearchScope.Subtree,
                                        attributeList: null);
    request.Controls.Add(pageControl);
    request.Controls.Add(delControl);
    
    bool mOre = true;
    SearchResponse searchResponse;
    
    int count = 0;
    
    while (mOre)
    {
        searchResponse = (SearchResponse)conn.SendRequest(request);
        foreach (var entry in searchResponse.Entries)
        {
            .
            .
            .
        }
    
        PageResultResponseControl pgControl = searchResponse.Controls.OfType<PageResultResponseControl>().FirstOrDefault(page => page!=null && page.Cookie != null && page.Cookie.Length > 0);
        mOre = pgControl.Cookie != null && pgControl.Cookie.Length > 0;
        pageControl.Cookie = pgControl.Cookie;
    }


    Monday, January 11, 2016 8:08 AM

Answers