Abandon() public method

Abandons all outstanding operations managed by the queue. All operations in progress, which are managed by the specified queue, are abandoned.
LdapException A general exception which includes an error /// message and an Ldap error code. ///
public Abandon ( LdapMessageQueue queue ) : void
queue LdapMessageQueue The queue returned from an asynchronous request. /// All outstanding operations managed by the queue /// are abandoned, and the queue is emptied. /// ///
return void
Esempio n. 1
0
    public static void Main(String[] args)
    {
        if (args.Length != 3)
        {
            Console.WriteLine(
                "Usage:   mono EdirEventSample <host name> <login dn>"
                + " <password> ");
            Console.WriteLine(
                "Example: mono EdirEventSample Acme.com \"cn=admin,o=Acme\""
                + " secret ");
            Environment.Exit(0);
        }

        int ldapPort = LdapConnection.DEFAULT_PORT;
        int ldapVersion = LdapConnection.Ldap_V3;
        String ldapHost = args[0];
        String loginDN = args[1];
        String password = args[2];

        LdapResponseQueue queue = null;

        LdapConnection lc = new LdapConnection();

        try
        {
            // connect to the server
            lc.Connect(ldapHost, ldapPort);

            // authenticate to the server
            lc.Bind(ldapVersion, loginDN, password);

            //Create an Array of EdirEventSpecifier
            EdirEventSpecifier[] specifier = new EdirEventSpecifier[1];

            //Register for all Add Value events.
            specifier[0] =
                new EdirEventSpecifier(EdirEventType.EVT_CREATE_ENTRY,
                //Generate an Value Event of Type Add Value
                EdirEventResultType.EVT_STATUS_ALL
                //Generate Event for all status
                );

            //Create an MonitorEventRequest using the specifiers.
            MonitorEventRequest requestoperation =
                new MonitorEventRequest(specifier);

            //Send the request to server and get the response queue.
            queue = lc.ExtendedOperation(requestoperation, null, null);

        }

        catch (LdapException e)
        {
            Console.WriteLine("Error: " + e.ToString());
            try
            {
                lc.Disconnect();
            }
            catch (LdapException e2)
            {
                Console.WriteLine("Error: " + e2.ToString());
            }
            Environment.Exit(1);
        }

        catch (Exception e)
        {
            Console.WriteLine("Error: " + e.ToString());
        }

        Console.WriteLine("Monitoring the events for {0} minutes..", TIME_OUT_IN_MINUTES );
        Console.WriteLine();

        //Set the timeout value
        timeOut= DateTime.Now.AddMinutes(TIME_OUT_IN_MINUTES);

        try
        {
            //Monitor till the timeout happens
            while (DateTime.Now.CompareTo(timeOut) < 0)
            {
                if (!checkForAChange(queue))
                    break;
                System.Threading.Thread.Sleep(10);
            }
        }

        catch (System.IO.IOException e)
        {
            Console.WriteLine(e.Message);
        }

        catch (System.Threading.ThreadInterruptedException e)
        {
            Console.WriteLine(e.Message);
        }

        //disconnect from the server before exiting
        try
        {
            lc.Abandon(queue); //abandon the search
            lc.Disconnect();
        }

        catch (LdapException e)
        {
            Console.WriteLine();
            Console.WriteLine("Error: " + e.ToString());
        }

        Environment.Exit(0);
    }
Esempio n. 2
0
        static void Main(string[] args)
        {
            if ( args.Length != 5)
            {
                Console.WriteLine("Usage:   mono SearchPersist <host name> <ldap port>  <login dn>" + " <password> <search base>" );
                Console.WriteLine("Example: mono SearchPersist Acme.com 389"  + " \"cn=admin,o=Acme\"" + " secret \"ou=sales,o=Acme\"");
                return;
            }

            int ldapVersion  = LdapConnection.Ldap_V3;
            String ldapHost = args[0];
            int ldapPort = Convert.ToInt32(args[1]);;
            String loginDN = args[2];
            String password = args[3];
            String searchBase = args[4];
            LdapSearchQueue queue = null;
            LdapSearchConstraints constraints;
            LdapPersistSearchControl psCtrl;
            LdapConnection lc = new LdapConnection();
            constraints =  new LdapSearchConstraints();

            try
            {
                // connect to the server
                lc.Connect( ldapHost, ldapPort );
                // authenticate to the server
                lc.Bind(ldapVersion, loginDN, password);

                //Create the persistent search control
                psCtrl = new LdapPersistSearchControl(
                    LdapPersistSearchControl.ANY, // any change
                    true,                         //only get changes
                    true,                         //return entry change controls
                    true);                        //control is critcal

                // add the persistent search control to the search constraints
                constraints.setControls( psCtrl );

                // perform the search with no attributes returned
                String[] noAttrs = {LdapConnection.NO_ATTRS};
                queue = lc.Search(
                    searchBase,                // container to search
                    LdapConnection.SCOPE_SUB,  // search container's subtree
                    "(objectClass=*)",         // search filter, all objects
                    noAttrs,                   // don't return attributes
                    false,                     // return attrs and values, ignored
                    null,                      // use default search queue
                    constraints);              // use default search constraints
            }
            catch( LdapException e )
            {
                Console.WriteLine( "Error: " + e.ToString() );
                try { lc.Disconnect(); }
                catch(LdapException e2) {  }
                Environment.Exit(1);
            }
            catch(Exception e)
            {
                Console.WriteLine( "Error: " + e.Message );
                return;
            }

            Console.WriteLine("Monitoring the events for {0} minutes..", TIME_OUT_IN_MINUTES );
            Console.WriteLine();

            //Set the timeout value
            timeOut= DateTime.Now.AddMinutes(TIME_OUT_IN_MINUTES);

            try
            {
                //Monitor till the timeout happens
                while (DateTime.Now.CompareTo(timeOut) < 0)
                {
                    if (!checkForAChange(queue))
                        break;
                    System.Threading.Thread.Sleep(10);
                }
            }
            catch (System.IO.IOException e)
            {
                System.Console.Out.WriteLine(e.Message);
            }
            catch (System.Threading.ThreadInterruptedException e)
            {
            }

            //Disconnect from the server before exiting
            try
            {
                lc.Abandon(queue); //abandon the search
                lc.Disconnect();
            }
            catch (LdapException e)
            {
                Console.Out.WriteLine();
                Console.Out.WriteLine("Error: " + e.ToString());
            }

            Environment.Exit(0);
        }