Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling DTS from ASP.NET

Status
Not open for further replies.

keith818

Programmer
Jun 19, 2002
10
GB
I have written a function to call a DTS package from a c# DLL. The function looks as follows:

public bool RunBulkInsert() {
DTS.Package2Class dtsBulkInsert;
object objPersistStgOfHost = null;
UCOMIConnectionPointContainer cpcCnnctPtCont;
UCOMIConnectionPoint cpConnectionPoint;
PackageEventsSink pesPackageEventsSink;
Guid gidPackageEvents;
int intCookie;

try {
dtsBulkInsert = new DTS.Package2Class();
cpcCnnctPtCont = (UCOMIConnectionPointContainer) dtsBulkInsert;

pesPackageEventsSink = new PackageEventsSink ();
// UUID of PackageEvents Interface.
gidPackageEvents = new Guid("10020605-EB1C-11CF-AE6E-00AA004A34D5");
cpcCnnctPtCont.FindConnectionPoint(ref gidPackageEvents, out cpConnectionPoint);

cpConnectionPoint.Advise(pesPackageEventsSink, out intCookie);

// Get reference to DTS package.
dtsBulkInsert.LoadFromSQLServer(Globals.DatabaseServerName, "keith", "dts",
DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_Default,
null, null, null, Globals.EDWImportDTSJob, ref objPersistStgOfHost);

// Execute DTS package.
dtsBulkInsert.Execute();

cpConnectionPoint.Unadvise(intCookie);
}
catch {
return false;
}
return true;
}

When I call this function from a windows app it works fine but when I call it from an ASP.NET app I get the following error:
“Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection”

I am running the website using Integrated Windows Authentification and have
<authentication mode="Windows" />
<identity impersonate="true">
set in the web.config.

When I run the code, the debugger is in the function RunBulkInsert() and look at the
System.Security.Principal.WindowsIdentity.GetCurrent() the correct user appears when I’m running it from the windows app and web app.

Also I have tried specifying the user name and password in the LoadFromSQLServer command but I still get them same error.

Any suggestions?

Thanks in advance,

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top