This application offers a simple system for maintaining a database of suppliers and products. It provides functions for adding updating, retrieving and deleting suppliers and products. All database access is simulated.
There are two classes, Supplier and Product, that form the basis for the components in this application.
The application has been programmed for Dynamic Registration, which means that the COM+ application the components belong to will automatically be created the first time one of the classes is invoked, provided that the calling application has Administrator privileges. Review the AssemblyInfo file, where the assembly attributes that enable dynamic registration are located.
On the data input form you can add a supplier, by entering a Company Name and Phone and clicking Add Supplier. To update, enter a Company Name, Phone and ID. To delete a supplier, only an ID is needed. If the operation is successful, a message on the status line will indicate that. Working with products is similar.
Each class writes to the Output Window when various events occur, such as instantiation, activation, and deactivation. See the DoTracing procedure in each class. You can uncomment the lines that make it also write to the Event Log. Review these entries to track the life cycle of the components.
Set breakpoints at various places in the classes to see the sequence of events as an object is used in the Enterprise Services environment.
Two roles are created for this application: Managers and Clerks. Managers will have complets access to both the Supplier and Product components. Clerks have access only to the Product component. See the classes for the security attributes that enable role-based security.
Important: Roles are created automatically when the application is first executed and added to the COM+ Catalog, but user accounts must manually be added to the roles, using the COM+ Explorer.
To test access permissions, run the application and click Get Suppliers or Get Products. This will invoke one of the components and cause the application to be installed in COM+. Exit the application and manually add user accounts to the Managers and Clerks roles, using the COM+ Explorer. Then log on as each user and test for allowed access.
As an alternative to implementing roles using attributes, as is done in this example, you can achieve the same result programatically. By using the Component Services Administration (COMAdmin) Library, you can automate just about all the actions that are possible in the COM+ Explorer, including:
Note, however, that assemblies placed in the global assembly cache require manual registration.
See Automating COM+ Administration for more.