Tuesday, March 27, 2012

Forms Authentication Example not safe for multi-threaded applications

I thought this might be useful for other Reporting Services users.
This relates both the Forms Authentication Example from Microsoft, and
the problem it was giving me loading the Authorization Extension:
http://groups.google.com/groups?selm=f284ebe.0409271146.279ecf4c%40posting.google.com&output=gplain
After contacting Microsoft, and getting their help with this problem,
it was determined that the solution was to use SyncLock on the
InitializeMaps method of the AuthorizationExtension class in the
example. That is, in VB:
Private Shared Sub InitializeMaps()
SyncLock GetType(AuthorizationExtension)
<Code as it appears in example>
End SyncLock
End Sub
This resolved our problem. I hope others find this useful.
- TerryWhat is the equivalent code for C#. I found the InitializeMaps() method in
the Authorization.cs file, but it is not clear how you would apply the
synclock option. Also I found no reference to syncLock in the C# help file.
"Terry Romance" wrote:
> I thought this might be useful for other Reporting Services users.
> This relates both the Forms Authentication Example from Microsoft, and
> the problem it was giving me loading the Authorization Extension:
> http://groups.google.com/groups?selm=f284ebe.0409271146.279ecf4c%40posting.google.com&output=gplain
> After contacting Microsoft, and getting their help with this problem,
> it was determined that the solution was to use SyncLock on the
> InitializeMaps method of the AuthorizationExtension class in the
> example. That is, in VB:
> Private Shared Sub InitializeMaps()
> SyncLock GetType(AuthorizationExtension)
> <Code as it appears in example>
> End SyncLock
> End Sub
> This resolved our problem. I hope others find this useful.
> - Terry
>|||JB,
I know it's been a while and you've probably puzzled this out yourself by
now, but the equivalent C# structure is
lock (typeof(AuthorizationExtension)) {
<...method body here...>
}
FWIW,
-Marc
"jbmeeh" wrote:
> What is the equivalent code for C#. I found the InitializeMaps() method in
> the Authorization.cs file, but it is not clear how you would apply the
> synclock option. Also I found no reference to syncLock in the C# help file.sql

No comments:

Post a Comment