access is denied in sharepoint document library event handler word
From: hareesh (hareesh_at_discussions.microsoft.com)
Date: 06/29/05
- Previous message: Henrik Skak Pedersen: "Book on WS-Security"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Wed, 29 Jun 2005 09:55:02 -0700
I am opening wordapplication object (Have a reference to Microsfot Interop
assembly) on the server side in sharepoint document library even handler.
I am getting "access is denied" exception. The user is "SPSUser"
Can somebody please help me to overcome this exception.
My code : (getting expception when creating wordapplicaiton)
void IListEventSink.OnEvent(Microsoft.SharePoint.SPListEvent listEvent)
{
IntPtr tokenHandler =
System.Security.Principal.WindowsIdentity.GetCurrent().Token;
WindowsIdentity objWindowsIdentity = new WindowsIdentity(tokenHandler);
CloseHandle(tokenHandler);
WindowsImpersonationContext objWindowsImpersonationContext =
objWindowsIdentity.Impersonate();
try
{
if (listEvent.Type == SPListEventType.Insert)
{
SPWeb site = listEvent.Site.OpenWeb();
SPFile file = site.GetFile(listEvent.UrlAfter);
string fileName = file.Name;
int length = fileName.Length;
string fileExtension = fileName.Substring(length-3);
if(fileExtension.Equals("doc"))
{
wordApplication = new ApplicationClass();
.
.
. .
.
. objWordFormExtract.FileName = file.Url;
objWordFormExtract.LoadMyScenarioRecord(ref objScenarioRecord);
if (objScenarioRecord != null)
{
if(objScenarioRecord.StoreRecordInDataBase())
{ errorMessage = "Document is uploaded successfully"; }
}
else
{ errorMessage = objInfoPathFormExtract.ErrorMessage; }
}
}
}
- Previous message: Henrik Skak Pedersen: "Book on WS-Security"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|