Exemplo n.º 1
0
        public int setserver_pageControloption()
        {
            //set server control LDAP_OPT_SERVER_CONTROLS
            Berval berVal = new Berval(0, IntPtr.Zero);
            LDAPControl c = new LDAPControl(berVal, LdapMessage.LDAP_CONTROL_PAGEDRESULTS, 'F');
            IntPtr[] ctrls = new IntPtr[2];
            ctrls[0] = c.ConvertToUM();
            ctrls[1] = IntPtr.Zero;

            IntPtr arrayCtrls = IntPtr.Zero;

            // Allocate memory to store the array of pointers
            int sizeOfIntPtr = Marshal.SizeOf(typeof(IntPtr));
            arrayCtrls = Marshal.AllocCoTaskMem(sizeOfIntPtr * ctrls.Length);

            // Stuff the pointers into the array
            for (int counter = 0; counter < ctrls.Length; counter++)
                Marshal.WriteIntPtr(arrayCtrls, counter * sizeOfIntPtr, ctrls[counter]);

            int ret = Ldap_Set_Option(LDAP_OPT_SERVER_CONTROLS, arrayCtrls);

            return ret;
        }