/**
         * Used to Convert an RfcLDAPMessage object to the appropriate
         * LDAPIntermediateResponse object depending on the operation being performed.
         *
         * @param inResponse   The LDAPIntermediateResponse object as returned by the
         * extendedOperation method in the LDAPConnection object.
         * <br><br>
         * @return An object of base class LDAPIntermediateResponse.  The actual child
         *         class of this returned object depends on the operation being
         *         performed.
         *
         * @exception LDAPException A general exception which includes an error message
         *                          and an LDAP error code.
         */
        public static LdapIntermediateResponse ConvertToIntermediateResponse(RfcLdapMessage inResponse)

        // throws LDAPException
        {
            var tempResponse = new LdapIntermediateResponse(inResponse);

            // Get the oid stored in the Extended response
            var inOid = tempResponse.GetId();

            var regExtResponses =
                LdapIntermediateResponse.GetRegisteredResponses();

            try
            {
                var extRespClass = regExtResponses.FindResponseExtension(inOid);
                if (extRespClass == null)
                {
                    return(tempResponse);
                }

                Type[]    argsClass = { typeof(RfcLdapMessage) };
                object[]  args      = { inResponse };
                Exception ex;
                try
                {
                    var extConstructor = extRespClass.GetConstructor(argsClass);

                    try
                    {
                        object resp = null;
                        resp = extConstructor.Invoke(args);
                        return((LdapIntermediateResponse)resp);
                    }
                    catch (UnauthorizedAccessException e)
                    {
                        ex = e;
                    }
                    catch (TargetInvocationException e)
                    {
                        ex = e;
                    }
                }
                catch (MissingMethodException e)
                {
                    // bad class was specified, fall through and return a
                    // default  LDAPIntermediateResponse object
                    ex = e;
                }
            }
            catch (MissingFieldException ex)
            {
                // No match with the OID
                // Do nothing. Fall through and construct a default LDAPControl object.
                Logger.Log.LogWarning("Exception swallowed", ex);
            }

            // If we get here we did not have a registered extendedresponse
            // for this oid.  Return a default LDAPIntermediateResponse object.
            return(tempResponse);
        }
        static MonitorEventRequest()
        {
            /*
             * Register the extendedresponse class which is returned by the
             * server in response to a MonitorEventRequest
             */
            try
            {
                LdapExtendedResponse.register(EventOids.NLDAP_MONITOR_EVENTS_RESPONSE,
                                              Type.GetType("Novell.Directory.Ldap.Events.Edir.MonitorEventResponse", true));
            }
            catch (TypeLoadException e)
            {
                // TODO: put something in the Debug...
            }
            catch (Exception e)
            {
                // TODO: put something in the Debug...
            }

            //Also try to register EdirEventIntermediateResponse
            try
            {
                LdapIntermediateResponse.register(EventOids.NLDAP_EVENT_NOTIFICATION,
                                                  Type.GetType("Novell.Directory.Ldap.Events.Edir.EdirEventIntermediateResponse", true));
            }
            catch (TypeLoadException e)
            {
                // TODO: put something in the Debug...
            }
            catch (Exception e)
            {
                // TODO: put something in the Debug...
            }
        } // end of static constructor
示例#3
0
        /**
         * Used to Convert an RfcLDAPMessage object to the appropriate
         * LDAPIntermediateResponse object depending on the operation being performed.
         *
         * @param inResponse   The LDAPIntermediateResponse object as returned by the
         *                     extendedOperation method in the LDAPConnection object.
         * <br><br>
         * @return An object of base class LDAPIntermediateResponse.  The actual child
         *         class of this returned object depends on the operation being
         *         performed.
         *
         * @exception LDAPException A general exception which includes an error message
         *                          and an LDAP error code.
         */

        static public LdapIntermediateResponse convertToIntermediateResponse(RfcLdapMessage inResponse)
        //          throws LDAPException
        {
            LdapIntermediateResponse tempResponse = new LdapIntermediateResponse(inResponse);
            // Get the oid stored in the Extended response
            String inOID = tempResponse.getID();

            RespExtensionSet regExtResponses =
                LdapIntermediateResponse.getRegisteredResponses();

            try
            {
                Type extRespClass = regExtResponses.findResponseExtension(inOID);
                if (extRespClass == null)
                {
                    return(tempResponse);
                }

                Type[]    argsClass = new Type[] { typeof(RfcLdapMessage) };
                Object[]  args      = { inResponse };
                Exception ex;
                try
                {
                    ConstructorInfo extConstructor = extRespClass.GetConstructor(argsClass);

                    try
                    {
                        Object resp = null;
                        resp = extConstructor.Invoke(args);
                        return((LdapIntermediateResponse)resp);
                    }
                    catch (UnauthorizedAccessException e)
                    {
                        ex = e;
                    }
                    catch (TargetInvocationException e)
                    {
                        ex = e;
                    }
                }
                catch (MissingMethodException e)
                {
                    // bad class was specified, fall through and return a
                    // default  LDAPIntermediateResponse object
                    ex = e;
                }
            }
            catch (MissingFieldException)
            {
                // No match with the OID
                // Do nothing. Fall through and construct a default LDAPControl object.
            }
            // If we get here we did not have a registered extendedresponse
            // for this oid.  Return a default LDAPIntermediateResponse object.
            return(tempResponse);
        }
示例#4
0
 static MonitorEventRequest()
 {
     /*
      * Register the extendedresponse class which is returned by the
      * server in response to a MonitorEventRequest
      */
     LdapExtendedResponse.register(EventOids.NLDAP_MONITOR_EVENTS_RESPONSE, typeof(MonitorEventResponse));
     //Also try to register EdirEventIntermediateResponse
     LdapIntermediateResponse.register(EventOids.NLDAP_EVENT_NOTIFICATION, typeof(EdirEventIntermediateResponse));
 } // end of static constructor