I'm trying to understand how to properly implement a timeout for an OpenLDAP bind request to an LDAP server. From what I've found, there seems to be two ways to do this, with LDAP_OPT_TIMELIMIT and LDAP_OPT_TIMEOUT. My main confusion comes from trying to figure out what the difference is between these.
So far as I understand it, TIMELIMIT is an LDAP standard that sets the time limit for the request/response cycle for any ldap search. And in Windows at least, the default is 120 seconds.
On the other hand TIMEOUT is OpenLDAP specific and used purely client-side for timing out LDAP bind requests. This actually sounds closest to what I want to implement. I know from discussions that using an ldap_set_opt for TIMEOUT was not fully implemented until 2.4. From How can I cause ldap_simple_bind_s to timeout? I know that the work around for earlier versions is to use an asynchronous bind, followed by an ldap_result with the timeout and an ldap_abandon_ext in the case of timeout to drop the request. That makes sense, though looking through the source code for synchronous bind in version 2.4, it doesn't ever seem to handle a timeout in this way. This makes me wonder what the importance of calling ldap_abandon_ext is.
Any answers or insight would be appreciated.
If anyone is looking for OpenLDAP bind timeout yet, you should use method from Aki's answer here.
It is also working in ldapcpp library, when using LDAPAsynConnection for bind. Before bind you must just enable it using getSessionHandle() method.
Related
I'm trying enrich using dynamically selected remote files on an FTP server using pollEnrich. The remote files must remain in place and can be selected again and again so the endpoint has noop=true and idempotent=false. Everything seems to work fine until multiple requests start coming in that use the same remote file for enrichment, and this results in all but a few of the requests receiving a null body for the new exchange argument in the aggregation strategy. Here is the relevant part of the route, which has been modified slightly to post here:
.pollEnrich()
.simple("ftp://username:password#ftp.example.com/path/files?fileName=${header.sourceFilename}&passiveMode=true&noop=true&idempotent=false")
.timeout(0)
.cacheSize(-1)
.aggregationStrategy(myEnrichmentAggregationStrategy)
I switched to using file:// instead of ftp:// as a test and still experienced the same problems. I also tried different modes for timeout, cacheSize, and also enabling streamCaching since the body is an InputStream. I'm now thinking about implementing a custom read-lock mechanism (processStrategy) but it feels like a long shot workaround. Has anyone else come across this problem and can shed some light on what's wrong?
I believe I've found a solution and it is using the inProgressRepository property on the polling consumer to set a dummy implementation of IdempotentRepository, allowing me to disable the check for in progress files.
I am writing an application which will be used for event sending. As it stands right now the application is done, however in the future there will be additions to the application. Those additions will be new versions. My question is how to actually implement those version. Sure I can go for "if version == xx" but doing that in every method, in constructors, just does not seem as the exact solution, that's why I am asking for help from people with experience in implementing those versions. Thanks!
The problem you are facing can be handled with implementing forward compatibility. Unfortunately, I cannot give you any practical advice without knowing anything about your protocol. There are some general steps you could follow, though:
Only change the protocol if you really have to.
Ensure you do not break backward compatibility.
Force the user to update the application when update the protocol. This ensures there is only one valid version at a time.
If you have to support multiple versions of the protocol you could implement some kind of converter. But this might not work in every case.
I'll deal the problem with Interfaces and Factory pattern.
For example:
Create an Interface with all the methods.
Create differents implementations for each version.
Use Factory to get the proper implementation
I'm not really sure how to handle the scenario I have in a good code manner.
The basic of the criteria of my work is this:
A WPF application that consumes a WCF service
The service uses per session instancing
The session starts soon after application is started and should live through the application lifetime (with small exceptions)
Some method calls in a session must precede and be finished before others are called
This means I will have to be able to have one instance of a proxy client throughout the whole application. I will also have to be able to handle async calls, so the client won't hang up, but at the same time ensure they are finished.
My technical understanding go WCF is limiting enough to not know if certain scenarios would work as intended. So I'm going to list my uncertainties:
When does a session start and when does it end. Is it based on the creation of clients or could a separate client instance access the same session if the first would go faulted.
What is the best way to handle exceptions through a WCF service
Is ChannelFactory something I should look at to help me put here.
So what I did in the first iteration to try to solve some of these problems.
I used dependency injection to inject the client instance throughout the classes of my WPF application (I'm using MVVM) to ensure the same instance is everywhere.
I made the service reference using the asynchronous generation method to get the Begin and End versions of all methods to ensure the calls would be async
I used the Coroutine (IResult interface) feature of the Caliburn.Micro framework to ensure one async action is finished before the other begins (have no idea if this is a proper usage or if it is a smart move at all).
Problems I still have is of course how to handle a faulted state of the client. I'm assuming right now that I could reinstance the client and either rescue the session or I could actually just set it up again as it was. I now need to reinstance it everyplace I injected it in with the same new instance.
So I though perhaps it would be best to create a ClientManager class that would wrap the Client. That way I could inject this ClientManager and reinstance inside of him if needed. I guess I should expose him outwards to be able to make method calls but it would be great if I could error handle inside him in somehow. I'm just having a hard time testing my methods and I'm never certain it will work properly in integration because I don't understand all of the inner workings of WCF, coroutines and threading.
Is there anyone out there with more experience then me in these matters that could give me a few pointers or at least tell me how WCF works in these situations ( per session ) and what I'm doing wrong and what right.
WCF supports sessions out-of-box, so I would recommend starting with this MSDN article.
At a very high level, first you set SessionMode=SessionMode.Required in your ServiceContract. And then, set the IsInitiating=True and IsTerminating=True properties on your OperationContract's to mark the start and end of each session.
However, note that WCF limits concurrent sessions by default to 16 to prevent DOS attacks, but you can always up the value. Also, you would have realized that the session is valid as long as its host (IIS / Windows Service / other) is not recycled.
On a related note, I have used WCF Durable Services earlier - which are meant to persist the state of your WCF service in a data-store (default is SQL Server). Ofcourse, there is a performance hit here. Suggest reading further to see if this is the right choice for you.
Hope this helps.
This is driving me nuts.
I'm making a SSH Tunnelling application, and need to be able to automatically force the system to use HTTP & Socks5 proxies, and have the changes take effect instantly.
HTTP proxies are now taken care of perfectly by the PoshHTTP class , but I can't figure out how to do the same with SOCKS5.
I've already tried forcing the changes in the registry, but they don't take effect instantly and it's just not reliable. In most cases I had to open internet options > lan settings before the settings would take effect, so the user may as well have set the proxy up manually by this point.
Is there a way to do this that I'm missing ? It would be amazing if I could just modify poshHTTP to do this, but I don't have high hopes.
Please help.. I did search like mad for days before posting but I'm running out of ideas and this app needs to be launched ASAP. Thanks!
I'm willing to Pay $50USD for a workable c# solution, that takes effect immediately (Paid via PayPal only)
That really dependes on what kind of socks5 authentication type it's required
have youtried this? http://code.msdn.microsoft.com/windowsdesktop/CSWebBrowserWithProxy-c8535715#content
Other places you could look at are http://www.codeproject.com/Articles/336/SOCKS-Proxy-SSL-Tunnel and http://www.codeproject.com/Articles/5954/C-class-for-connecting-via-a-SOCKS5-Proxy-Server
In WPF (in code behind) is there a way to detect whether the computer that the client application is running on has access to the internet?
I'm not sure if there is a simple dedicated method / property to check this or whether I would have to try an HttpGet or similar to determine this.
Is there a property or method for this purpose?
-- Lee
It depends on what you consider "access to the internet"
Safest is to add a 'ping' service to the server you wish to connect to and poll that service.
Trying to keep track of the network status is much harder because it is hard to find out whether it is an intranet other type of network.
See this post too
I don't think there's a simple dedicated method or property.
The simplest solution would be to try to connect to your server and then check the error state.