Tải bản đầy đủ (.pdf) (86 trang)

Tài liệu Module 4: Managing Transactions and State pptx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.12 MB, 86 trang )







Contents
Overview 1
COM+ Context 2
The IObjectContext Interface 6
Lab 4.1 Using Context Object Services 15
Just In Time Activation 18
Managing Transactions 25
Programming COM+ Transactions 38
Lab 4.2 Managing Transactions 48
Managing State 51
Using the Shared Property Manager 59
Lab 4.3 Storing State in the Middle Tier 69
Best Practices 74
Review 76

Module 4: Managing
Transactions and State


Information in this document is subject to change without notice. The names of companies,
products, people, characters, and/or data mentioned herein are fictitious and are in no way intended
to represent any real individual, company, product, or event, unless otherwise noted. Complying
with all applicable copyright laws is the responsibility of the user. No part of this document may
be reproduced or transmitted in any form or by any means, electronic or mechanical, for any
purpose, without the express written permission of Microsoft Corporation. If, however, your only


means of access is electronic, permission to print one copy is hereby granted.

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual
property rights covering subject matter in this document. Except as expressly provided in any
written license agreement from Microsoft, the furnishing of this document does not give you any
license to these patents, trademarks, copyrights, or other intellectual property.

 2000 Microsoft Corporation. All rights reserved.

Microsoft, BackOffice, MS-DOS, Windows, Windows NT, Intellisense, PowerPoint, and Visual
Basic are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or
other countries.

The names of companies, products, people, characters, and/or data mentioned herein are fictitious
and are in no way intended to represent any real individual, company, product, or event, unless
otherwise noted.

Other product and company names mentioned herein may be the trademarks of their respective
owners.


Module 4: Managing Transactions and State iii


Instructor Notes
This module describes transactions and related concepts and issues. Students
learn to activate and deactivate components by using Just In Time (JIT)
Activation and As Soon As Possible (ASAP) deactivation. They will learn to
use the Shared Property Manager (SPM) to manage state. This module also
covers best programming practices to increase application scalability and

efficiency.
After completing this module, students will be able to:
!
Use the context object to retrieve information about a COM+ component.
!
Add transaction support for COM+ components by using the Component
Services tool.
!
Enable JIT Activation for COM+ components.
!
Create COM+ components that support and manage distributed transactions.
!
Use the SPM to manage the application data referred to as state.
!
Describe some of the best practices when managing transactions and state.

In the first two labs, students will learn how to use the context object services to
retrieve information about the context object and to manage transactions. In the
third lab, students will use the Shared Property Manager to store state in the
middle tier of the Purchase Order Online application.
Materials and Preparation
This section provides you with the required materials and preparation tasks that
are needed to teach this module.
Required Materials
To teach this module, you need the following materials:
!
Microsoft PowerPoint
®
file 1907A_04.ppt
!

Module 4: Managing Transactions and State
!
Lab 4.1: Using Context Object Services
!
Lab 4.2: Managing Transactions
!
Lab 4.3: Storing State in the Middle Tier

Preparation Tasks
To prepare for this module, you should:
!
Read all of the materials for this module.
!
Complete the labs.
!
Read the instructor notes and the margin notes for the module.

Presentation:
135 Minutes

Lab:
90 Minutes
iv Module 4: Managing Transactions and State


Module Strategy
Use the following strategy to present this module:
!
COM+ Context
Discuss the concept of an object’s context and how each COM+ object is

created with an associated context. For components that do not use COM+
services, the context is largely ignored. However, for components running
inside COM+ applications, contexts are the foundation on which COM+
services are provided. The context object information is exposed through
several interfaces on the ObjectContext object.
!
Just In Time Activation
Discuss how JIT Activation is used to create an object when a COM+
component is instantiated. JIT Activation helps make COM+ solutions
scalable by activating objects as they are required and by preventing idle
objects from consuming valuable resources on the server.
!
Managing Transactions
Discuss how transactions can be managed automatically by using COM+
services. Describe the purpose of transactions in an enterprise solution.
Transactions are required to maintain data integrity and to synchronize
updates to data in multiple data sources.
!
Programming COM+ Transactions
Explain that sometimes developers need to control transactions
programmatically even though they can be managed declaratively through
COM+ services. The main reason for programming COM+ transactions is to
gain a greater degree of control over the process. For example, a component
may enforce a business rule that causes a transaction to abort if certain
conditions arise, such as a balance transfer exceeding a specified maximum
amount. Discuss the context object interfaces and how they are used to
program COM+ transactions.
!
Managing State
Discuss that state refers to the data used within the business processes of an

application. When building enterprise solutions, managing state is a major
design concern. Explain that components can be stateful or stateless, and
discuss the implications on component design resulting from state.
!
Using the Shared Property Manager
Discuss how the SPM is a resource dispenser provided by COM+ to store
transient shared data in a COM+ application. The SPM allows you to retain
global data between component activations and share it among all
component instances in the COM+ application process.
!
Best Practices
Summarize all the best practices taught in the module.
Module 4: Managing Transactions and State v


Demonstration
This section provides demonstration procedures that will not fit in the margin
notes or that are not appropriate for the student notes.
Using the ObjectControl Interface
!
Explain the demonstration scenario
• The demonstration scenario is based on the Northwind database. A COM+
application is used to discontinue products that are no longer available. The
client application calls a component named Traders, which invokes its
DiscontinueProduct method. The Traders component calls a component
named EventLog, invoking its LogEvent method to record the name of the
user discontinuing the product. Next, Traders calls a component named
Product, which invokes its Discontinue method to update the Products
table. If an error occurs, Traders calls a component named ErrorLog,
invoking its LogError method to record the error information and the

ActivityID of the COM+ activity.

!
Run the test client
1. Run the NwindClient.exe client application from the <install
folder>\Democode\Mod04\NorthwindClient folder.
2. Enter a number below 100 and click Discontinue. A message will confirm
the discontinued product.
3. Enter a number over 200 and click Discontinue. An error message will be
displayed.

!
Examine the database
1. Start Enterprise Manager from the Microsoft SQL Server 7.0 program
group.
2. Expand the nodes in the Tree pane to view the tables in the Northwind
database.
3. View the contents of the EventLog table and note the name of the user
recorded there by the Traders component.
4. View the contents of the ErrorLog table and note the ActivityID recorded
there by the Traders component.

!
Examine the component code
1. Open Northwind.vbp in the <install
folder>\Democode\Mod04\NorthwindComponent folder.
2. Display the code for the Traders class and examine the
DiscontinueProduct method.
3. Under the comment Declare Object Context variable, add the following
variable declaration:

Dim objCtx As COMSVCSLib.ObjectContext

vi Module 4: Managing Transactions and State


4. Under the comment Get a reference to the Object Context, add the
following code:
Set objCtx = COMSVCSLib.GetObjectContext

5. Point out the following line of code:
strUser = "Graeme" 'Get name from ISecurityProperty

6. Change this line to the following:
strUser = objCtx.Security.GetOriginalCallerName

7. Point out the following line of code in the error handler:
strActivity = "{00000000-0000-0000-0000-000000000000}"

8. Change the code to:
strActivity = objCtx.ContextInfo.GetActivityID

9. Save and recompile the component (you may need to shut down the
Northwind COM+ application) and close Microsoft Visual Basic.

!
Run the test client
1. Run the NwindClient.exe client application from the <install
folder>\Democode\Mod04\NorthwindClient folder.
2. Enter a number below 100 and click Discontinue. A message will confirm
the discontinued product.

3. Enter a number over 200 and click Discontinue. An error message will be
displayed.

!
Examine the database
1. Start Enterprise Manager from the SQL Server 7.0 program group.
2. Expand the nodes in the Tree pane to view the tables in the Northwind
database.
3. View the contents of the EventLog table and note the name of the user
recorded there by the Traders component.
4. View the contents of the ErrorLog table and note the ActivityID recorded
there by the Traders component.

Managing Transactions
!
To prepare for the demonstration
!
Ensure the SetupDemos.cmd file has been executed as previously described.

!
Run the test client
1. Run the NwindClient.exe client application from the <install
folder>\Democode\Mod04\NorthwindClient folder.
2. Enter a number below 100 and click Discontinue. A message will confirm
the discontinued product.
3. Enter a number over 200 and click Discontinue. An error message will be
displayed.
Module 4: Managing Transactions and State vii




!
Examine the database
1. Start Enterprise Manager from the SQL Server 7.0 program group.
2. Expand the nodes in the Tree pane to view the tables in the Northwind
database.
3. View the contents of the EventLog table and note that events have been
recorded for product updates that did not take place. Explain that the reason
is that the business process is not atomic.

!
Configure the COM+ components
1. Open the Component Services administration tool and display the properties
of the components in the Northwind application.
2. Point out that the Traders component does not support transactions. Change
its Transaction support attribute to Required.
3. Ask students to explain why the Transaction support property of the
ErrorLog component is set to Requires New.
4. Shut down the Northwind application and close Component Services.

!
Add code to commit or abort the transaction
1. Open Northwind.vbp in the <install
folder>\Democode\Mod04\NorthwindComponent folder.
2. Display the code for the Traders class and examine the
DiscontinueProduct method.
3. Add the following line of code under the comment Commit Transaction:
objCtx.SetComplete

4. Add the following line of code under the comment Abort Transaction:

objCtx.SetAbort

5. Save and recompile the project and close Visual Basic.

!
Run the test client
1. Run the NwindClient.exe client application from the <install
folder>\Democode\Mod04\NorthwindClient folder.
2. Enter a number below 100 and click Discontinue. A message will confirm
the discontinued product.
3. Enter a number over 200 and click Discontinue. An error message will be
displayed.

!
Examine the database
1. Start Enterprise Manager from the SQL Server 7.0 program group.
2. Expand the nodes in the Tree pane to view the tables in the Northwind
database.
3. View the contents of the EventLog table and note that events have not been
recorded for product updates that did not take place. Explain that the reason
is that the business process is not an atomic transaction.

Module 4: Managing Transactions and State 1


#
##
#

Overview

!
COM+ Context
!
Lab 4.1: Using Context Object Services
!
Just In Time(JIT) Activation
!
Managing Transactions
!
Programming COM+ Transactions
!
Lab 4.2: Using Context to Manage Transactions
!
Managing State
!
Using the Shared Property Manager
!
Lab 4.3: Storing State in the Middle Tier
!
Best Practices and Review


In this module, you will learn how to use the context object to obtain security,
transactional, and other information about COM+ components. You will learn
how COM+ uses Just In Time (JIT) Activation to free system resources and
improve performance. You will also learn how to manage distributed
transactions both declaratively and programmatically. Finally, you will learn
how to manage state by using the Shared Property Manager (SPM).
Objectives
After completing this module, you will be able to:

!
Use the context object to retrieve information about a COM+ component.
!
Add transaction support for COM+ components by using the Component
Services tool.
!
Enable JIT Activation for COM+ components.
!
Create COM+ components that support and manage distributed transactions.
!
Use the Shared Property Manager to manage the application data referred to
as state.

2 Module 4: Managing Transactions and State


#
##
#

COM+ Context
!
Overview of the Context Object
!
Interfaces for the Context Object
!
The IObjectContext Interface
!
The IContextInfo Inteface
!

The ISecurityProperty Interface
!
The IContextState Interface
!
Demonstration: The Context Object


Every COM object is created with an associated context. For components that
do not use COM+ services, the context is largely ignored. However, for
components running inside COM+ applications, contexts are the foundation on
which COM+ services are provided. The context object information is exposed
through an object named ObjectContext.
This section includes the following topics:
!
Overview of the Context Object
!
Interfaces for the Context Object
!
The IContextInfo Interface
!
The ISecurityProperty Interface
!
The IContextState Interface
!
Demonstration: The Context Object

Module 4: Managing Transactions and State 3


Overview of the Context Object

Client
COM+ Component
Context


The data that COM+ uses to keep track of what each object is doing is referred
to as an object's context. Each context must be associated with a particular
context object that monitors its properties. The context object, which is named
ObjectContext, maintains information about the object and its current status,
including:
!
Whether the object is involved in a transaction.
!
What the object is currently doing.
!
The security level of the component.
!
The identity of the object’s caller.
!
Security role membership of the object’s caller.
!
A Done flag to control the object’s activation and lifetime.
!
A Consistency flag to control transactional behavior.

Shared Context
When an object is instantiated, it is either associated with an existing context or
a new context is created for it. If a client program creates an instance of a
COM+ component, a new context will be created for the component. If the
COM+ component then instantiates another component with a compatible

configuration, the new component will be created in the same context. The
following illustration shows the relationship between the client, the COM+
components, and the associated shared context.
4 Module 4: Managing Transactions and State



Inherited Context
Some components, such as those that require transactions, are not compatible
with the component that called them and a new context must be created. When
a new context is required, COM+ allows certain properties to flow from the
calling context to the new context. For example, if the calling component is in a
transaction and the called component supports transactions, a new context will
be created for the called component because each transactional component
requires its own context to vote on the transaction outcome. However, the
TransactionID and ActivityID properties will be inherited from the calling
context so that the new component can participate in the same transaction and
the same logical business process. The following illustration shows how the
new component inherits certain properties from the calling component.

In this illustration, the calling component creates a second component that
requires its own context. The new context inherits some properties from the
calling context despite having it has its own separate context.
Module 4: Managing Transactions and State 5


Interfaces for the Context Object
Dim objCtx As COMSVCSLib.ObjectContext
Dim objInfo As COMSVCSLib.ContextInfo
Dim objSec As COMSVCSLib.SecurityProperty

Dim objSt As COMSVCSLib.IContextState
Set objCtx = COMSVCSLib.GetObjectContext()
Set objInfo = objCtx.ContextInfo
Set objSec = objCtx.Security
Set objSt = objCtx
ObjectContext
IObjectContext
IContextState
ContextInfo
Security
IUnknown


The context object provides a number of interfaces that can be used to retrieve
context information and control the object’s behavior.
You can retrieve most context information that you will need by using the
IObjectContext interface. This interface provides a wide range of methods and
properties that you can use to create an instance of a component, retrieve
security information, and retrieve and manage transactions. This interface can
be obtained programmatically by using the GetObjectContext function, which
is provided by COM+.
The IObjectContext interface contains two properties that are themselves
objects. These objects are the ContextInfo and Security objects and they
implement the IContextInfo and ISecurityProperty interfaces, respectively.
The IContextInfo interface provides methods and properties relating to the
status of the context, including the Context ID, the GUID identifying the
activity to which the object instance belongs and other useful logging
information.
The ISecurityProperty interface provides information about the caller’s
identity and is also useful for logging. You should note however that the

ISecurityProperty interface is provided mostly for backward compatibility
with MTS and that a separate interface named ISecurityCallContext provides
a more flexible approach to programmatic security.
Finally, the ObjectContext object also implements an interface named
IContextState that provides methods for controlling object lifetime and
transactions. This interface can be obtained by calling GetObjectContext or by
assigning an IContextState variable to an instantiated ObjectContext object.
Each of these interfaces is discussed in more detail later in this section.
6 Module 4: Managing Transactions and State



The IObjectContext Interface
$
CreateInstance
$
DisableCommit
$
EnableCommit
$
IsCallerInRole
$
IsInTransaction
$
IsSecurityEnabled
$
SetAbort
$
SetComplete
!

Methods of the IObjectContext Interface
Dim objCtx As COMSVCLib.ObjectContext
Set objCtx = GetObjectContext
If objCtx.IsInTransaction Then
‘Do Something
End If


The IObjectContext interface provides the methods described in the following
table.
Method Description

CreateInstance Creates an instance of another COM+ component (method
required for backward compatibility with code written for
Microsoft Transaction Server only).
DisableCommit Prevents a transaction from committing temporarily.
EnableCommit Allows a transaction to commit.
IsCallerInRole Checks the role membership of the caller.
IsInTransaction Determines whether the object is in a transaction.
IsSecurityEnabled Determines if security checking is enabled for the
component.
SetAbort Declares that a transaction must be aborted.
SetComplete Declares a component as ready to commit the transaction.

The IObjectContext interface provides the properties described in the
following table.
Property Description

ContextInfo Provides an object with further methods and properties relating to
the context.

Count Returns the number of named context object properties.
Item Returns a specific named property.
Security Provides an object with further methods and properties relating to
security.

Module 4: Managing Transactions and State 7


Accessing the Context Object
To access the ObjectContext object, you must set a reference to the COM+
Services Type Library. Afterward, you can access the ObjectContext object by
using the GetObjectContext method, as shown in the following code.
If GetObjectContext.IsInTransaction Then
' Do Something
Else
' Do Something Else
End If

You can either use the GetObjectContext method each time you need to access
the ObjectContext object or you can declare a variable of type
COMSVCLib.ObjectContext and instantiate it by using the GetObjectContext
method. You can then use the variable to access the properties and methods of
ObjectContext, as shown in the following code:
Dim objCtx As COMSVCLib.ObjectContext
Set objCtx = GetObjectContext
If objCtx.IsInTransaction Then
'Do Something
End If



8 Module 4: Managing Transactions and State


The IContextInfo Interface
!
Methods of the IContextInfo Interface
$
IsInTransaction
$
GetTransaction
$
GetTransactionID
$
GetActivityID
$
GetContextID
Dim objCtx As COMSVCSLib.ObjectContext
Dim strActID As String
Set objCtx = GetObjectContext
strActID = objCtx.ContextInfo.GetActivityID


The IContextInfo interface contains status information about the context
object. The ContextInfo object is a property of the ObjectContext object that
implements the IContextInfo interface.
Methods of the IContextInfo Interface
The IContextInfo interface provides the following methods.
Method Description

IsInTransaction Determines whether the object is in a transaction. (The same

method is available on the Context object.)
GetTransaction Retrieves a pointer to the ITransaction interface of the
current transaction. (This interface does not support
Automation from Microsoft Visual Basic
®
.)
GetTransactionID Retrieves a unique value identifying the transaction (if any)
in which the object is participating.
GetActivityID Retrieves a unique value identifying the activity of which the
object is a part.
GetContextID Retrieves a unique value identifying the context object.

Accessing ContextInfo Methods
You can access the methods of the ContextInfo object through the
ObjectContext as shown in the following code:
Dim objCtx As COMSVCSLib.ObjectContext
Dim strActID As String
Set objCtx = GetObjectContext
strActID = objCtx.ContextInfo.GetActivityID

Module 4: Managing Transactions and State 9


Alternatively, you can declare a variable of type COMSVCSLib.ContextInfo
and instantiate it by using the ContextInfo property of the ObjectContext as
shown in the following code:
Dim objCtx As COMSVCSLib.ObjectContext
Dim objCtxInfo As COMSVCSLib.ContextInfo
Dim strActID As String
Set objCtx = GetObjectContext

Set objCtxInfo = objCtx.ContextInfo
strActID = objCtxInfo.GetActivityID


10 Module 4: Managing Transactions and State


The ISecurityProperty Interface
!
Methods of the ISecurityProperty Interface
$
GetDirectCallerName
$
GetDirectCreatorName
$
GetOriginalCallerName
$
GetOriginalCreatorName
Dim objCtx as COMSVCSLib.ObjectContext
Dim strUsrName as string
Set objCtx = GetObjectContext
strUserName = objCtx.Security.GetOriginalCallerName


You can use the ISecurityProperty interface to retrieve information about the
caller of a component. The Security property of the ObjectContext is an object
that implements the ISecurityProperty interface.
Methods of the ISecurityProperty Interface
The ISecurityProperty interface provides the following methods.
Method Description


GetDirectCallerName Retrieves the name of the user account of the process
calling this component directly.
GetDirectCreatorName Retrieves the name of the user account of the process
that created this object (for backward compatibility
with Microsoft Transaction Server).
GetOriginalCallerName Retrieves the name of the user account of the process
that started the current call chain.
GetOriginalCreatorName Retrieves the name of the user account of the process
that created the object at the beginning of the call
chain (for backward compatibility with Microsoft
Transaction Server).

Module 4: Managing Transactions and State 11


Accessing SecurityProperty Methods
You can access the methods of the ISecurityProperty interface through the
ObjectContext object’s Security property, as shown in the following code.
Dim objCtx as COMSVCSLib.ObjectContext
Dim strUsrName as string
Set objCtx = GetObjectContext
strUserName = objCtx.Security.GetOriginalCallerName

Alternatively, you can instantiate a variable of type
COMSVCSLib.SecurityProperty by using the Security property of
ObjectContext, as shown in the following code.
Dim objCtx as COMSVCSLib.ObjectContext
Dim objCtxScy as COMSVCSLib.SecurityProperty
Dim strUsrName as string

Set objCtx = GetObjectContext
Set objCtxScy = objCtx.Security
strUsrName = objCtxScy.GetOriginalCallerName


You can also access security methods and properties through the
ISecurityCallContext interface. This interface provides greater functionality
than the ISecurityProperty interface and should usually be used to manage
programmatic security. For more information about the ISecurityCallContext
interface, see Module 8: Making Applications Secure.

Note
12 Module 4: Managing Transactions and State


The IContextState Interface
!
Methods of the IContextState interface
$
SetDeactivateOnReturn
$
SetMyTransactionVote
$
GetDeactivateOnReturn
$
GetMyTransactionVote
!
Used to control activation and transactions



The IContextState interface is a COM interface that contains methods to
control the Done and Consistency flags. Although these flags are usually set by
using the SetComplete, SetAbort, DisableCommit, and EnableCommit
methods of the ObjectContext interface, you can get a finer level of control by
using the IContextState interface. The SetComplete, SetAbort,
DisableCommit, and EnableCommit methods of the ObjectContext interface
are discussed later in this module.
Methods of the IContextState Interface
The IContextState interface provides the following methods.
Method Description

SetDeactivateOnReturn Sets the Done flag
SetMyTransactionVote Sets the Consistency flag
GetDeactivateOnReturn Returns the value of the Done flag
GetMyTransactionVote Returns the value of the Consistency flag

Accessing the IContextState Interface
The IContextState interface is implemented by the ObjectContext class. You
can access the IContextState interface by instantiating a variable of type
COMSVCSLib.IContextState, either by using the GetObjectContext function
or by using an already instantiated ObjectContext object variable.
You can use the GetObjectContext function to instantiate the IContextState
interface, as shown in the following code.
Dim objCxSt As COMSVCSLib.IContextState
Set objCxSt = GetObjectContext

Module 4: Managing Transactions and State 13


Alternatively, you can access the IContextState interface through an already

instantiated ObjectContext object, as shown in the following code.
Dim objCx As COMSVCSLib.ObjectContext
Dim objCxSt As COMSVCSLib.IContextState
Set objCx = GetObjectContext
Set objCxSt = objCx

14 Module 4: Managing Transactions and State


Demonstration: The Context Object


In this demonstration, you will be shown how to access the IObjectContext,
ISecurityProperty, and IContextInfo interfaces by using the ObjectContext
object.
Delivery Tip
The step-by-step
instructions for this
demonstration are in the
instructor notes for this
module.
Module 4: Managing Transactions and State 15


Lab 4.1 Using Context Object Services


In this lab, you will use the services of the context object in the
POBusiness.bus_Order component. The context object provides information
about the context of the current object instance. You will use some of this

information to identify the user who is calling the component.
Objectives
After completing this lab, you will be able to:
!
Use properties of the context object.

Prerequisites
Before working on this lab, you should be familiar with the following:
!
COM+ context

Exercises
The following exercise provides practice working with the concepts and
techniques covered in this module:
!
Exercise 1: Using the Security Property
In this exercise, you will use the Security property of the context object to
identify the user who is calling the component.

Estimated time to complete this lab: 30 minutes
Slide Objective
To introduce the lab.
Lead-in
In this lab, you will use the
services of the context
object in the
POBusiness.bus_Order
component to identify who is
calling the component.
16 Module 4: Managing Transactions and State



Exercise 1:
Using the Security Property
In this exercise, you will use the Security property of the context object to
identify the user who is calling the component.
!
Set a reference to the COM+ Services Type Library
1. Open the POBusiness.vbp project that you saved in Lab 3.2. If you did not
complete Lab 3.2, open the POBusiness.vbp project in <install
folder>\Labs\Lab04\POBusiness.
2. On the Project menu, click References.
3. Select the COM+ Services Type Library check box.
4. Click OK.

!
Declare a variable for the security property
In this procedure, you will display the code window for the bus_Order class
module, and in the Raise method, declare the following variables:
1. Declare a variable objCtx of type COMSVCSLib.ObjectContext.
2. Declare a variable objSec of type COMSVCSLib.SecurityProperty

!
Use the security object
In this procedure, you will replace the code strUser = “Student” with code to
do the following:
1. Instantiate objCtx by using the GetObjectContext function.
2. Instantiate objSec by assigning it to the Security property of objCtx.
3. Use the GetOriginalCallerName method of objSec to assign a value to
strUser.


!
Test the component
1. Compile the POBusiness.dll in the same folder as the project and save the
project. (If Visual Basic cannot overwrite the existing DLL, use the
Component Services administrative tool to shut down the Purchase Order
COM+ application).
2. Close Visual Basic.
3. Use the Web-based Purchase Order Online application to place an order.
4. Note the order number when it is displayed.
5. On the Start menu, point to Programs, Microsoft SQL Server 7.0, and
then click Query Analyzer.
6. Log on to the (local) SQL Server and use Windows NT Authentication.
7. In the Query window, select PurchaseOrderSystem from the DB drop-
down list.
Module 4: Managing Transactions and State 17


8. Enter the following SQL query in the Query window, and then click
Execute Query.
SELECT * FROM orderheader

9. Note that the last order placed has a RaisedBy value showing the full
Windows 2000 user name (DomainX\Student) of the user who placed it.

×