public override LdapResultCompleteStatus Handle(SafeHandle handle, Native.Native.LdapResultType resType, IntPtr msg, out DirectoryResponse response)
        {
            response = default;
            switch (resType)
            {
            case LdapForNet.Native.Native.LdapResultType.LDAP_RES_ADD:
                response = new AddResponse();
                return(LdapResultCompleteStatus.Complete);

            default:
                return(LdapResultCompleteStatus.Unknown);
            }
        }
Beispiel #2
0
        public override LdapResultCompleteStatus Handle(SafeHandle handle, Native.Native.LdapResultType resType,
                                                        IntPtr msg, out DirectoryResponse response)
        {
            response = default;
            switch (resType)
            {
            case LdapForNet.Native.Native.LdapResultType.LDAP_RES_EXTENDED:
                var    requestName  = IntPtr.Zero;
                var    requestValue = IntPtr.Zero;
                string name         = null;
                byte[] value        = null;
                var    rc           = Native.ldap_parse_extended_result(handle, msg, ref requestName, ref requestValue, 0);
                if (rc == (int)LdapForNet.Native.Native.ResultCode.Success)
                {
                    if (requestName != IntPtr.Zero)
                    {
                        name = Encoder.Instance.PtrToString(requestName);
                        Native.ldap_memfree(requestName);
                    }

                    if (requestValue != IntPtr.Zero)
                    {
                        var berval = Marshal.PtrToStructure <Native.Native.berval>(requestValue);
                        if (berval.bv_len != 0 && berval.bv_val != IntPtr.Zero)
                        {
                            value = new byte[berval.bv_len];
                            Marshal.Copy(berval.bv_val, value, 0, berval.bv_len);
                        }

                        Native.ldap_memfree(requestValue);
                    }
                }

                response = new ExtendedResponse
                {
                    ResultCode    = (Native.Native.ResultCode)rc,
                    ResponseName  = name,
                    ResponseValue = value
                };
                msg = IntPtr.Zero;
                return(LdapResultCompleteStatus.Complete);

            default:
                return(LdapResultCompleteStatus.Unknown);
            }
        }
        public override LdapResultCompleteStatus Handle(SafeHandle handle, Native.Native.LdapResultType resType, IntPtr msg, out DirectoryResponse response)
        {
            response = _response;
            LdapResultCompleteStatus resultStatus;

            switch (resType)
            {
            case LdapForNet.Native.Native.LdapResultType.LDAP_RES_SEARCH_ENTRY:
                var ber = Marshal.AllocHGlobal(IntPtr.Size);
                try
                {
                    var directoryEntries = GetLdapEntries(handle, msg, ber).ToList();
                    _response.Entries.AddRange(directoryEntries);

                    OnPartialResult(_response.MessageId, directoryEntries);
                }
                finally
                {
                    Marshal.FreeHGlobal(ber);
                    Native.ldap_msgfree(msg);
                }

                resultStatus = LdapResultCompleteStatus.Partial;
                break;

            case LdapForNet.Native.Native.LdapResultType.LDAP_RES_SEARCH_REFERENCE:
                var reference = GetLdapReference(handle, msg);
                if (reference != null)
                {
                    _response.References.Add(reference);
                }
                resultStatus = LdapResultCompleteStatus.Partial;
                break;

            case LdapForNet.Native.Native.LdapResultType.LDAP_RES_SEARCH_RESULT:
                resultStatus = LdapResultCompleteStatus.Complete;
                break;

            default:
                resultStatus = LdapResultCompleteStatus.Unknown;
                break;
            }

            return(resultStatus);
        }
        public override LdapResultCompleteStatus Handle(SafeHandle handle, Native.Native.LdapResultType resType, IntPtr msg, out DirectoryResponse response)
        {
            response = default;
            switch (resType)
            {
            case LdapForNet.Native.Native.LdapResultType.LDAP_RES_SEARCH_ENTRY:
                var ber = Marshal.AllocHGlobal(IntPtr.Size);
                _response.Entries.AddRange(GetLdapEntries(handle, msg, ber));
                Marshal.FreeHGlobal(ber);
                Native.ldap_msgfree(msg);
                return(LdapResultCompleteStatus.Partial);

            case LdapForNet.Native.Native.LdapResultType.LDAP_RES_SEARCH_REFERENCE:
                return(LdapResultCompleteStatus.Partial);

            case LdapForNet.Native.Native.LdapResultType.LDAP_RES_SEARCH_RESULT:
                response = _response;
                return(LdapResultCompleteStatus.Complete);

            default:
                return(LdapResultCompleteStatus.Unknown);
            }
        }
Beispiel #5
0
 public override LdapResultCompleteStatus Handle(SafeHandle handle, Native.Native.LdapResultType resType,
                                                 IntPtr msg, out DirectoryResponse response)
 {
     throw new NotImplementedException();
 }
Beispiel #6
0
 public abstract LdapResultCompleteStatus Handle(SafeHandle handle, Native.Native.LdapResultType resType, IntPtr msg,
                                                 out DirectoryResponse response);