You can call Dispose manually (which is what "using" does for you at the end of the block).
You could also have the switch block to just assign the selected name to a string variable and then move the DirectoryEntry instance creation that is something like :
using (DirectoryEntry entry = new DirectoryEntry(LDAPAddress, LDAPusername, LDAPPassword))
{
using (DirectorySearcher TestSearcher = new DirectorySearcher(entry))
{
//fetch data
}
}
Participant
1443 Points
2030 Posts
Dispose objects and using connection pooling while fetching LDAP
Feb 21, 2014 09:50 AM|venkatzeus|LINK
Hi,
I am using a webservice, where I am fetching the User's Active directory from LDAP.
However, I am getting Error While Connection to LDAP AD intermittenlty. out of 100 times the search called it is Returning this error 30 times.
Exception: Server was unable to process request. ---> The server is not operational
I have used the below code:
How to use the ConnectionPooling effectively to fix the issue?
I have checked the site : http://blogs.dirteam.com/blogs/tomek/archive/2007/08/09/system-directoryservices-and-connection-pooling.aspx
But, I am not sure how to use the "Using" block in the above code, since it is in a switch block.
Thanks
All-Star
48730 Points
18189 Posts
Re: Dispose objects and using connection pooling while fetching LDAP
Feb 21, 2014 10:06 AM|PatriceSc|LINK
Hi,
You can call Dispose manually (which is what "using" does for you at the end of the block).
You could also have the switch block to just assign the selected name to a string variable and then move the DirectoryEntry instance creation that is something like :
All-Star
35149 Points
9075 Posts
Re: Dispose objects and using connection pooling while fetching LDAP
Feb 21, 2014 03:16 PM|smirnov|LINK
It does not seem to be an issue with pooling as you have less calls than default 5000 as per description.
For me it looks like a problem which is described here
http://stackoverflow.com/questions/1883165/strange-issue-with-system-directoryservices-accountmanagement-userprincipal-find
and you should try to dispose as suggested by PatriceSc.
Participant
1443 Points
2030 Posts
Re: Dispose objects and using connection pooling while fetching LDAP
Feb 22, 2014 12:34 AM|venkatzeus|LINK
HI,
Would the below code also be required, as descrbed in the blog, which I posted in the initial question
Thanks
All-Star
35149 Points
9075 Posts
Re: Dispose objects and using connection pooling while fetching LDAP
Feb 22, 2014 03:06 AM|smirnov|LINK
As I said I think your issue is different and RefreshCache is not required. Anyway you need to try and see how it works.
Participant
1443 Points
2030 Posts
Re: Dispose objects and using connection pooling while fetching LDAP
Feb 25, 2014 07:47 AM|venkatzeus|LINK
Hi,
Is this correct?
Thanks
All-Star
35149 Points
9075 Posts
Re: Dispose objects and using connection pooling while fetching LDAP
Feb 25, 2014 08:39 AM|smirnov|LINK
Nope, try