473,396 Members | 1,895 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,396 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
Nov 22 '05 #1
0 1038

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...
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...
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...
4
by: Uchiha Jax | last post by:
Hello everyone, I am a plenty silly person who is trying to learn .NET remoting through trial and error (all articles I read are going over my head at the moment (mostly) so I thought i'd give...
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: ...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.