PC Review


Reply
Thread Tools Rate Thread

C# Remoting/COM security E_ACCESSDENIED error

 
 
Natalia DeBow
Guest
Posts: n/a
 
      6th May 2004
Hi there,

I am trying to create shortcuts to a desktop and to a Start->Programs menu
from a C# client talking to a server (using .NET Remoting) that in turn
talks to a COM object. I am running both the client and the server code on
the same machine with the client having Administrators privileges. The
server is running under IIS with ASPNET account having Users privileges
only. We do use impersonate = true in our web.config file. I am trying to
create a shortcut for an account that is created on the same machine as the
client and the server. I have also logged in at least once into this
account, so the profile for this account does indeed exist and the password
is set to never expire. This account has Users privileges only.

Here is the function that should create shortcuts, but it chokes when I am
trying to save the .lnk file to a specified folder.

More specifically the line:
hres = ppf->Save(wsz, TRUE);
returns E_ACCESSDENIED and the next line:
hres = ppf->Release();
returns S_FAIL.

The strange thing is when we are trying to created multiple shortcuts for an
app (say, app.exe), the first attempt always fails but consecutive tries
succeed.

Here is the function that creates shortcuts.
BOOL CreateShortcut(LPCSTR lpszFolderName,

LPCSTR lpszProgName,

LPCSTR lpszEXE,

LPCSTR lpszCommand,

LPCSTR lpszWorkingDirectory,

LPCSTR lpszDescription)

{


HRESULT hres;

IShellLink* psl;

char FullPath[MAX_PATH];



CoInitialize(0);

hres = CoCreateInstance(CLSID_ShellLink, 0,

CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&psl);


if (SUCCEEDED(hres))

{

IPersistFile* ppf;

hres = psl->SetPath(lpszEXE);


if (SUCCEEDED(hres))

{

hres = psl->SetArguments(lpszCommand);


if (SUCCEEDED(hres))

{

hres = psl->SetWorkingDirectory(lpszWorkingDirectory);

if (SUCCEEDED(hres))

{

hres = psl->SetDescription(lpszDescription);


if (SUCCEEDED(hres))

{

hres = psl->QueryInterface(IID_IPersistFile, (void**) &ppf);


if (SUCCEEDED(hres))

{

WORD wsz[MAX_PATH];

sprintf(FullPath,"%s\\%s.lnk", lpszFolderName, lpszProgName);

int nMbwc = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, FullPath, -1, wsz,
MAX_PATH);

hres = ppf->Save(wsz, TRUE);

hres = ppf->Release();

}

}

}

}

}

hres = psl->Release();

}

CoUninitialize();

if FAILED(hres)

SetLastError(hres);

CONFIRM_PROCEED(SUCCEEDED(hres))

BOOL Success = BuildUnInstDB(FullPath);

CONFIRM_PROCEED(Success)

return TRUE;

}



Any help would be greatly appreciated.



Natalia


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with error 0x80070005 E_ACCESSDENIED when using TransactionScope Spottswoode Microsoft C# .NET 2 15th Mar 2007 07:14 PM
E_ACCESSDENIED under Windows 2000 when remoting an EXE server Dazz Murphy Microsoft Windows 2000 Security 0 15th Jan 2007 04:28 PM
Remoting...Because of security restrictions, the type System.Runtime.Remoting.ObjRef cannot be accessed. Junoti Microsoft C# .NET 0 11th Dec 2006 05:21 AM
Remoting callback error: "This remoting proxy has no channel sink =?Utf-8?B?RmVuZw==?= Microsoft VB .NET 0 25th Jan 2006 04:11 PM
Outlook 2002: Error -2147024891 Collaboration Data Objects E_ACCESSDENIED (80070005) Gayathrie Gunawardene Microsoft Outlook 0 29th Dec 2003 11:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:29 PM.