all groups > dotnet component services > april 2005 >
You're in the

dotnet component services

group:

COM+ Method level security problem


Re: COM+ Method level security problem Gabriel Lozano-Morán
4/26/2005 12:00:00 AM
dotnet component services:
Plost post an extraction of the class to see how exactly you use the
Enterprise Services

Gabriel Lozano-Morán

[quoted text, click to view]

COM+ Method level security problem bsmith NO[at]SPAM thrulogic.com
4/26/2005 5:01:55 AM
Hello,

I'm trying to use COM+, method level security...

Have a vb.net dll class that inhertis from servicedcomponent, has
strong name, TLB, registered in GAC and COM+. Have applied
ComponentAccessControl(), SecureMethod() to class level and
SecurityRole to specific methods I want to allow acess to given
roles...am getting error:

Method-level role based security requires an interface definition for
class method.

I am new to COM+ - have used MTS in the past but am starting to wonder
if I should be using web services instead, or .net remoting...but have
had read conflicting reports on all of these? and can't seem to find
ANY helpful information regarding this error....

any comment or help will be much appreciated.

Thanks,
Re: COM+ Method level security problem BSmith
4/26/2005 1:32:02 PM
Imports System.Runtime.InteropServices
Imports System.EnterpriseServices

<ClassInterface(ClassInterfaceType.AutoDual), _
ComponentAccessControl(), SecureMethod()> _
Public Class ClientServices
Inherits System.EnterpriseServices.ServicedComponent

Public Function CreateNewClient(ByVal Name As Object) As Integer

Dim sql As String
Dim NewID As Integer

sql = gBuildStoredProcSQL("ClientAddNew", Name)
NewID = gExecuteWithSingleResult(sql)

Return NewID

End Function

<SecurityRole("AppUser")> _
Public Function FetchClient(ByVal ClientID As Integer)

Dim sql As String

sql = gBuildStoredProcSQL("ClientFetch ", ClientID)
Return gExecuteWithResults(sql)

End Function


<SecurityRole("AppSuperUser")> _
Public Function FetchClientAccounts _
(ByVal ClientID As Integer) As DataTable

Dim sql As String

sql = gBuildStoredProcSQL("ClientAccountsFetch", ClientID)
Return gExecuteWithResults(sql)

End Function

End Class

Re: COM+ Method level security problem Gabriel Lozano-Morán
4/27/2005 12:00:00 AM
Add the following interface:

Public Interface IClientServices
Function FetchClient(ByVal ClientID As Integer)
Function FetchClientAccounts(ByVal ClientID As Integer) As DataTable
End Interface


Change the following lines:

ClassInterface(ClassInterfaceType.None)

Public Class ClientServices
Inherits ServicedComponent
Implements IClientServices


Gabriel Lozano-Morán

Re: COM+ Method level security problem Gabriel Lozano-Morán
4/27/2005 12:00:00 AM
[quoted text, click to view]

Because you use method level security you need to explicitly declare an
interface.

[quoted text, click to view]

this is called object pooling and can be disabled with the attribute
objectpooling (see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemEnterpriseServicesObjectPoolingAttributeClassTopic.asp)
but use it wisely :)

Some articles you can read about COM+:
http://msdn.microsoft.com/msdnmag/issues/01/10/complus/
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet11262002.asp

Gabriel Lozano-Morán

Re: COM+ Method level security problem Brendon
4/27/2005 1:25:16 PM
Thanks for your reply.
I made the changes you suggested and got it working
eventually*.

Is this method required in all cases or is it a workaround
- if not then why does the Interface generated by VS (with
Register for Com interap optin checked) not work?

Brendon.


*at first it didn't work but second time it did - is it
possible COM+ is caching dll's somewhere - I had COM+ admin
consol open the first time?


Re: COM+ Method level security problem anonymous NO[at]SPAM discussions.microsoft.com
4/28/2005 8:46:32 AM
Thanks - I've got another question regarding
programatically detecting roles, but I'll post as a new thread.


[quoted text, click to view]
/html/frlrfSystemEnterpriseServicesObjectPoolingAttributeClassTopic.asp)

[quoted text, click to view]
AddThis Social Bookmark Button