M
MP
Hi,
I have a library in which I use the COM+ services dynamically for
creating a Folder in the virtual directory of the Web Application on
the Web Server.
As ASPNET account does not have enough previlages I Impersonate a user
account at run time that has enough previlages to create a folder on
the web server.
Following is my code.
/// <summary>
/// Creates the event email folder.
/// </summary>
/// <param name="eventId">The event id.</param>
/// <returns></returns>
public static bool CreateEventEmailFolder(int eventId)
{
bool isFolderCreated = false;
Impersonate impersonate = new
Impersonate(LogonProvider.LOGON32_PROVIDER_WINNT50);
try {
impersonate.ImpersonateUser(EmailConfiguration.FolderManagerImpersonatedUser,
EmailConfiguration.FolderManagerImpersonatedDomain,
EmailConfiguration.FolderManagerImpersonatedPassword);
ServiceConfig config = new
ServiceConfig();
config.TrackingEnabled = true;
config.TrackingAppName =
"EmailFolderCreator Application";
config.TrackingComponentName =
"EmailFolderCreator";
config.Transaction =
TransactionOption.Required;
ServiceDomain.Enter(config);
//Check if the method is running in a
transaction
DirectoryInfo directoryInfo = new
DirectoryInfo(EmailConfiguration.EmailImagesFolderRootPath + "\\Event_"
+ eventId);
if(directoryInfo.Exists) {
directoryInfo.Delete(true);
directoryInfo.Create();
}
else {
directoryInfo.Create();
}
isFolderCreated = true;
}
catch(Exception ex) {
// so, we should abort the transaction
ContextUtil.SetAbort();
// we got an exception so process the
exception
ExceptionValidator.ProcessException(ex);
}
finally {
ServiceDomain.Leave();
impersonate.UndoImpersonation();
}
return isFolderCreated;
}
After the folder is created in the web server the folder is locked by
some process and I am no longer able to use the folder through the web
application for uploading or accessing files within this folder.
When I tried to investigate I found the the "EmailFolderCreator
Application" COM+ application is running contiously in Running services
node of the COM+ MMC under the aspnet_wp.exe client application. If I
kill the aspnet_wp.exe worker process I am able to access the folder. I
believe the aspnet_wp.exe worker process is locking the newly created
folder. Is there any way so that the aspnet_wp.exe worker process does
not lock the folder or releases the "EmailFolderCreator Application"
COM+ application from the running processes node immediately after I
leave the COM+ context.
Thanks in advance for any solutions.
Mahesh Mahangare
I have a library in which I use the COM+ services dynamically for
creating a Folder in the virtual directory of the Web Application on
the Web Server.
As ASPNET account does not have enough previlages I Impersonate a user
account at run time that has enough previlages to create a folder on
the web server.
Following is my code.
/// <summary>
/// Creates the event email folder.
/// </summary>
/// <param name="eventId">The event id.</param>
/// <returns></returns>
public static bool CreateEventEmailFolder(int eventId)
{
bool isFolderCreated = false;
Impersonate impersonate = new
Impersonate(LogonProvider.LOGON32_PROVIDER_WINNT50);
try {
impersonate.ImpersonateUser(EmailConfiguration.FolderManagerImpersonatedUser,
EmailConfiguration.FolderManagerImpersonatedDomain,
EmailConfiguration.FolderManagerImpersonatedPassword);
ServiceConfig config = new
ServiceConfig();
config.TrackingEnabled = true;
config.TrackingAppName =
"EmailFolderCreator Application";
config.TrackingComponentName =
"EmailFolderCreator";
config.Transaction =
TransactionOption.Required;
ServiceDomain.Enter(config);
//Check if the method is running in a
transaction
DirectoryInfo directoryInfo = new
DirectoryInfo(EmailConfiguration.EmailImagesFolderRootPath + "\\Event_"
+ eventId);
if(directoryInfo.Exists) {
directoryInfo.Delete(true);
directoryInfo.Create();
}
else {
directoryInfo.Create();
}
isFolderCreated = true;
}
catch(Exception ex) {
// so, we should abort the transaction
ContextUtil.SetAbort();
// we got an exception so process the
exception
ExceptionValidator.ProcessException(ex);
}
finally {
ServiceDomain.Leave();
impersonate.UndoImpersonation();
}
return isFolderCreated;
}
After the folder is created in the web server the folder is locked by
some process and I am no longer able to use the folder through the web
application for uploading or accessing files within this folder.
When I tried to investigate I found the the "EmailFolderCreator
Application" COM+ application is running contiously in Running services
node of the COM+ MMC under the aspnet_wp.exe client application. If I
kill the aspnet_wp.exe worker process I am able to access the folder. I
believe the aspnet_wp.exe worker process is locking the newly created
folder. Is there any way so that the aspnet_wp.exe worker process does
not lock the folder or releases the "EmailFolderCreator Application"
COM+ application from the running processes node immediately after I
leave the COM+ context.
Thanks in advance for any solutions.
Mahesh Mahangare