Exemplo n.º 1
0
        /// <summary>
        /// Creates a CompareResponse packet.
        /// </summary>
        /// <param name="context">The user context which contains message ID.</param>
        /// <param name="resultCode">Result code of previous request, as specified in RFC 2251.</param>
        /// <param name="matchedDn">Matched DN.</param>
        /// <param name="errorMessage">Error message for result code. Required.</param>
        /// <param name="referral">Referral. Optional. Used for LDAP v3 only.</param>
        /// <returns>The packet that contains the response.</returns>
        internal override AdtsCompareResponsePacket CreateCompareResponse(
            AdtsLdapContext context,
            MsLdap.ResultCode resultCode,
            string matchedDn,
            string errorMessage,
            string[] referral)
        {
            CompareResponse compareResponse = new CompareResponse(
                new LDAPResult_resultCode((long)resultCode),
                new LDAPDN(matchedDn ?? string.Empty),
                new LDAPString(errorMessage ?? string.Empty),
                CreateReferral(referral));

            LDAPMessage_protocolOp operation = new LDAPMessage_protocolOp();

            operation.SetData(LDAPMessage_protocolOp.compareResponse, compareResponse);

            LDAPMessage message = new LDAPMessage(new MessageID(context.MessageId), operation, null);
            AdtsCompareResponsePacket packet = new AdtsCompareResponsePacket();

            packet.ldapMessagev3 = message;
            packet.messageId     = context.MessageId;

            return(packet);
        }
Exemplo n.º 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_COMPARE:
                response = new CompareResponse();
                return(LdapResultCompleteStatus.Complete);

            default:
                return(LdapResultCompleteStatus.Unknown);
            }
        }
Exemplo n.º 3
0
        static void Compare()
        {
            string attributeName         = "description";
            string valueToCompareAgainst = "This is a sample OU";

            // create a request to do compare on the object
            CompareRequest compareRequest = new CompareRequest(
                ou1,
                attributeName,
                valueToCompareAgainst
                );

            // send the request through the connection
            CompareResponse compareResponse =
                (CompareResponse)dsmlConnection.SendRequest(compareRequest);

            Console.WriteLine("The result of the comparison is:" +
                              compareResponse.ResultCode);
        }
        /// <summary>
        /// Creates a CompareResponse packet.
        /// </summary>
        /// <param name="context">The user context which contains message ID.</param>
        /// <param name="resultCode">Result code of previous request, as specified in RFC 2251.</param>
        /// <param name="matchedDn">Matched DN.</param>
        /// <param name="errorMessage">Error message for result code. Required.</param>
        /// <param name="referral">Referral. Optional. Used for LDAP v3 only.</param>
        /// <returns>The packet that contains the response.</returns>
        internal override AdtsCompareResponsePacket CreateCompareResponse(
            AdtsLdapContext context,
            MsLdap.ResultCode resultCode,
            string matchedDn,
            string errorMessage,
            string[] referral)
        {
            CompareResponse compareResponse = new CompareResponse(
                new LDAPResult_resultCode((long)resultCode),
                new LDAPDN(matchedDn ?? string.Empty),
                new LDAPString(errorMessage ?? string.Empty),
                CreateReferral(referral));

            LDAPMessage_protocolOp operation = new LDAPMessage_protocolOp();
            operation.SetData(LDAPMessage_protocolOp.compareResponse, compareResponse);

            LDAPMessage message = new LDAPMessage(new MessageID(context.MessageId), operation, null);
            AdtsCompareResponsePacket packet = new AdtsCompareResponsePacket();
            packet.ldapMessagev3 = message;
            packet.messageId = context.MessageId;

            return packet;
        }