partial void BFOnViewAction(NSObject sender)
        {
            var q = GetQuery();

            if (q != null)
            {
                UIErrorHelper.ShowAlert(_qdto.GetFilterString(), "Query");
            }
        }
        public void Search(QueryDTO dto, Action <ILdapMessage, List <ILdapEntry> > fn)
        {
            List <ILdapEntry> entries;
            ILdapMessage      ldMsg = null;

            MaintainSession(delegate()
            {
                ldMsg = ldConn.LdapSearchExtS(dto.SearchBase, (int)dto.SearchScope, dto.GetFilterString(), dto.AttrToReturn, dto.AttrOnly, IntPtr.Zero, 0);
            });
            if (ldMsg == null)
            {
                throw new Exception(VMDirConstants.ERR_NULL_CONN);
            }

            entries = ldMsg.GetEntries();
            if (fn != null)
            {
                fn(ldMsg, entries);
            }
            (ldMsg as LdapMessage).FreeMessage();
        }
        public void PagedSearch(QueryDTO qdto, int pageSize, IntPtr cookie, bool morePages, Action <ILdapMessage, IntPtr, bool, List <ILdapEntry> > fn)
        {
            ILdapMessage ldMsg = null;

            IntPtr[] serverControls   = { IntPtr.Zero };
            IntPtr   returnedControls = IntPtr.Zero;

            MaintainSession(delegate()
            {
                serverControls[0] = ldConn.LdapCreatePageControl(pageSize, cookie, true);

                ldMsg = ldConn.LdapSearchExtExS(qdto.SearchBase, (int)qdto.SearchScope, qdto.GetFilterString(),
                                                qdto.AttrToReturn, qdto.AttrOnly, qdto.TimeOut, qdto.SizeLimit, serverControls);

                ldConn.LdapParseResult(ldMsg, ref returnedControls, false);
                if (cookie != IntPtr.Zero)
                {
                    LdapClientLibrary.ber_bvfree(cookie);
                    cookie = IntPtr.Zero;
                }
                ldConn.LdapParsePageControl(returnedControls, ref cookie);

                morePages = ldConn.HasMorePages(cookie);

                if (returnedControls != IntPtr.Zero)
                {
                    LdapClientLibrary.ldap_controls_free(returnedControls);
                    returnedControls = IntPtr.Zero;
                }
                LdapClientLibrary.ldap_control_free(serverControls[0]);
                serverControls[0] = IntPtr.Zero;
            });

            List <ILdapEntry> entries = ldMsg.GetEntries();

            if (fn != null)
            {
                fn(ldMsg, cookie, morePages, entries);
            }

            (ldMsg as LdapMessage).FreeMessage();
        }