Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Component Services / April 2005

Tip: Looking for answers? Try searching our database.

COM+ Method level security problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brendon - 26 Apr 2005 13:01 GMT
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,
Brenodn.
Gabriel Lozano-Morán - 26 Apr 2005 17:57 GMT
Plost post an extraction of the class to see how exactly you use the
Enterprise Services

Gabriel Lozano-Morán

> Hello,
>
[quoted text clipped - 18 lines]
> Thanks,
> Brenodn.
BSmith - 26 Apr 2005 21:32 GMT
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
Gabriel Lozano-Morán - 27 Apr 2005 06:45 GMT
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
Brendon - 27 Apr 2005 21:25 GMT
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?
Gabriel Lozano-Morán - 27 Apr 2005 22:27 GMT
> 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?

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

> *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?

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/frlr
fSystemEnterpriseServicesObjectPoolingAttributeClassTopic.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/v
bnet11262002.asp


Gabriel Lozano-Morán
anonymous@discussions.microsoft.com - 28 Apr 2005 16:46 GMT
Thanks - I've got another question regarding
programatically detecting roles, but I'll post as a new thread.

>-----Original Message-----
>> Is this method required in all cases or is it a workaround
[quoted text clipped - 11 lines]
>objectpooling (see
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fSystemEnterpriseServicesObjectPoolingAttributeClassTopic.asp
)

>but use it wisely :)
>
[quoted text clipped - 5 lines]
>
>.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.