473,322 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

C# Remoting/COM security E_ACCESSDENIED error

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
Jul 21 '05 #1
0 1047

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sean Newton | last post by:
I am absolutely bewildered by now by the Microsoft.Samples SSPI and Security assemblies. I've been trying to set these up in a very straightforward harness in the way that I'd like to be able to...
15
by: anders | last post by:
Hi! I have a config file that looks like this: <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.runtime.remoting> <application> <service> <wellknown mode="SingleCall"...
0
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool including SourceOffSite, SourceAnyWhere and VSS Remoting This article makes a detailed...
15
by: Ron L | last post by:
We are working on a distributed VB.Net application which will access a SQL database located on a known server. Each client will run on the user's local machine. To implement this, we are trying...
5
by: LGHummel | last post by:
I'm trying to host a remoting app in IIS and am getting the following error: Failed to execute the request because the ASP.NET process identity does not have read permissions to the global...
5
by: Simon Verona | last post by:
I have a pair of functions that I'm calling using remoting - called readfile and writefile. The readfile works fine when called from the client PC. The writefile method returns an error: ...
0
by: Natalia DeBow | last post by:
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...
4
by: Sharon | last post by:
Hi, I'm using the remoting, and I have a remoting object that has a public event that other processes should register to it. But when the client process is registering to the remote event, it...
0
by: Kristian Reukauff | last post by:
Hi I have a problem with the .Net-Securty-Functions. I've got a client and a server. When I try to register a channel at the server with this line: ChannelServices.RegisterChannel(chan, false);...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.