FindByIdentity in System.DirectoryServices.AccountManagment Memory Issues

I am working on an active catalog app. In addition to the typical "Create new user", "Account enable / disable", "w70" my password, etc., it also manages application permissions for all client web applications. Application management is handled by thousands of AD groups, which are built from 3 letter codes for application, section and site. There are also hundreds of AD groups that determine which applications and locations the coordinator can provide. All of these groups, in turn, refer to other groups, so I usually filter the list of groups with the MemberOf property to find the groups the user directly belongs to (or everyone has permission to do everything). I have used the System.DirectoryServices.AccountManagment namespace extensively,using the FindByIdentity method in 31 places throughout the application. This method calls the private FindPrincipalByIdentRefHelper method in the inner ADStoreCtx class. SearchResultCollection is created but not deleted, so in the end, usually once or twice a day, the web server runs out of memory and all applications on the web server stop responding until the iis is reset because the resources used by the com objects are not ever transmitted.are not ever transmitted.are not ever transmitted.

There are places where I go back to the main directory objects, but there are many places where I use Principal properties - a significant improvement over the use of esoteric declaration property names in the .Net 2.0 service directory.

I contacted Microsoft about the issue and it was fixed in .Net 4.0, but they currently have no plans to fix it in 3.5 unless there are issues in the community.

I only found information on this in a few places

MDSN documentation in the community content state has a memory leak at the bottom (suppose I had to read that before using the method)

http://msdn.microsoft.com/en-us/library/bb345628.aspx

And the class in question is internal and does not expose SearchResultsCollection outside of the offending method, so I cannot get the results to get rid of them or inherit from the class and override the method.

So my questions

Has anyone else encountered this problem? If you could get around this?

Do I have any option other than overwriting the application not using any of the active .Net 3.5 directories?

thank

+2


source to share


2 answers


I faced the same error, and no, I have no workaround other than using the DirectoryEntry approach.



0


source


Wrap your calls in a directorysearcher inside a used block, and also wrap the final result inside a use block and call .Dispose () on the results explicitly. See the answer here:



Memory leak when using PrincipalSearcher.FindAll ()

0


source







All Articles