IIS Cannot Get Access to an Excel File for Users, But is OK for Me. Why? - excel

I have a program running as a service in IIS in Windows Server 2008 R2. The program has no problem creating a report in Excel. The problem occurs when it tries to get access to the Excel the that it has just created. This gives the users a 80070005 error right at this line of code:
Excel.Application excelSS = null;
excelSS = new Excel.Application(); <-- Error
Because at that point, the program has not tried to get access to the Excel file just yet, I believe the problem is not related to lack of access rights to the file. I believe the problem may have to do with locating the Excel program. This may have to do with the fact that the Excel is 32-bit and the Windows operating system is in 64-bit. I am not sure.
The strange thing is that I have no problem viewing the Excel report through IIS. Another IT guy also has no problem doing this. But normal users all have this problem trying to do the exact same thing. This all points to the high probability that this problem is related to "access rights". If it has to do with the setup of Excel, I would assume that everyone including me would have the same problem. This is very puzzling.
I have already tried all the tips that I can find in Internet:
Confirm that the Application-Pools in IIS uses IIS APPPOOL\DefaultAppPool user account.
Add a "Desktop" folder in system32 and in SysWOW64 under config\systemprofile and make sure the IIS APPPOOL\DefaultAppPool user account has read/write access to those folders.
Run DCOM-Config, and assign local access/launch/activation rights to IIS APPPOOL\DefaultAppPool under COM-Security. And make sure both 32-bit and 64-bit DCOM-Config get these settings.
Because of the fact that the users use "Windows Authentication" to run the program in IIS, I also make sure that the users can use their own user account to get access to the folder in IIS server that stores the Excel file.
I even go as far as adding IIS APPPOOL\DefaultAppPool to local admin user group.
The only tip that I cannot try is the fact that I cannot find "Microsoft Excel Application" listed in DCOM-Config program (Component Services --> Computers --> My Computer --> DCom Config). I am supposed to add launch/activate access rights to IIS APPPOOL\DefaultAppPool to "Microsoft Excel Application" in that list. But somehow "Microsoft Excel Application" is not in the list. I have tried looking for it in DCOM-Config in both System32 and SysWOW64 folders. This "seems" like where the problem is. But I am not sure about this because of the fact that I have no problem viewing the Excel report using my user account. If there was something wrong with the settings in Excel, I would think that none of us could view the Excel report.
I didn't have this problem when I had that program in Windows Server 2003 R2 - 32bit, or in Windows XP 32-bit.
I understand the issue about Microsoft want people not to use Office Automation in Windows Server 2008. And Microsoft wants people to use XML or something like that. But I also understand that people have tried this and can work around this. Because I am not the developer of that program, I really don't want to start changing that program. Therefore, I would like to be able to get the existing program to work.
Please help. Thanks in advance.
Jay Chan

Turned out this problem has to do with access rights. Seem like ASP.NET was running under the user's authentication (not surprising because I have set the web service to use "Windows Authentication"). And the user doesn't have permission to run Excel directly at the server. The solution is to use a special domain user account: (1) Assign the special user account as the local admin, (2) Assign the special user account as the "Specific user" for "ASP.NET Impersonation" for the web service.
I have a feeling that the special user account was somehow embedded in that specific web service. Therefore, the fix that I mentioned above may or may not work for other people. Unfortunately I don't know if this is true or not because I was not the developer of that web service. And I cannot find any where in the web service mentioning anything related to that specific user account.
I am glad that this is fixed.
Jay Chan

Related

SharePoint development nightmares

I thought I'd give SharePoint development a go, to broaden my understanding of Microsoft technologies and ran into a situation I refuse to understand.
I have a new web application created: http://localhost:11523 and set up the site collection as required. I can browse to the web site fine, without any issues, but now I want to start developing against this, using the object model.
Right, so after I struggled with SPSite site = new SPSite("http://localhost:11523"); I figured that I'm not running VS2008 in elevated permissions, so restarting VS I finally got one step further.
Whenever I step into my code, I get:
The Web application at
http://localhost:11523/ could not be
found.
I've Googled this without luck. The application is most definitely there, I can browse it, add web parts and go mad. I just can't seem to connect to it via Visual Studio.
Any ideas would be great.
EDIT
I thought I'd isolate my method, called "GetListFromSharePoint(string name)" into a test method (nUnit Framework) and to my surprise returned 9 entries from the list, as expected. When I dumped the method back into my web application (not SharePoint, trying to test the Composite Control through a normal Web site), and run into the mentioned problem.
This is in SharePoint 2007, and I'm developing on the same machine onto which SharePoint 2007 is installed.
This approach used to work, for some reason, I just can't get it to recognize SharePoint. The test stubs work find, just not the web application.
Edit 2
So there where a couple of things I "missed", which kind of solved the problem by itself.
Firstly, I was developing on a x64 Windows 2008 box, thus SharePoint 2007 was running in x64 mode. Cassini, turns out, is 32bit regardless of the platform you run it on, which caused some compiler bugs (I did not have IA64 compilers installed). After installing this, I figured out that the default web site (localhost:80) had been disabled by SharePoint.
Renabling the default web site, allowed me to create my web application as a virtual directory against it, which allowed my debugger compiler to run in x64.
My next challenge was access permissions. Because any new virtual directory on port 80 is assigned to the default application pool, is it assumed that the user does not have the right permissions, so I had to change my web application to run under my SharePoint web application's application pool.
The last thing I had to do was run my SharePoint code with elevated permissions.
Working like a charm :D
Note! Enable debug on your SharePoint web application....
Thanks,
Eric
(You have not specified version - assuming SharePoint 2010).
You need to decide what object model you want to use:
client (to be able to access the server from any other machine)
server (the one that you are trying now, can only be run locally).
Most likley reasons your code not work:
using "localhost" instead of ""computer name" in the Url. (I believe it is the reason.)
you are running your code not on the same machine as the SharePoint
you are running code under non-admin account
Check out how sites collections are configured in "Central Administration" site - urls associated with each site collection are listed there - make sure you are using correct one.
You can also try enumerating all site collections in SPWebApplication (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebapplication.sites.aspx) to start expiriments.
I dont think the SPSite connect through the IIS, and if SharePoint isn't set up to respond to localhost (done in the Central Administration) you wont be able to connect to that url. IIS works a bit different here since it relays the signals to "localhost" to the "web application instance".
Start by checking in your SharePoint Central Administration. Go to "Configure alternate access mappings" in the "System Settings" section. Here you have your SharePoint instances, there are three properties which you can see directly in the list; 'Internal URL', 'Zone' and 'Public URL for Zone'.
If the Internal URL isn't set to Localhost you wont be able to use that connection you suggested. It bay be improper to change this to another url as well, so simply try to set your SPSite site = new SPSite("http://yourinternalurl:11523"); to whatever's in that box! :)
Cheers

IIS ASP with OpenOffice - ActiveX Component Can't Create Object

I have an old website developed in classic ASP, I need to add openoffice functionality in it, so I have created a DLL using UNO services of OpenOffice in VB. I have tried that DLL from locally using in another EXE project and even on command line project.
The problem starts when I use that DLL to ASP. It says 'ActiveX Component Can't Create Object', I have searched a lot and finally I decided to ask some experts regarding this issue. As from my searches it says there is some issue with IIS security. I need to configure some directories with some particular user rights and some DCOM service configuration, seriously I don't know anything about setting user rights to IIS and setting DCOM Services rights, below are URL that points to that issue.
http://www.oooforum.org/forum/viewtopic.phtml?t=24400&highlight=activex+component
http://www.oooforum.org/forum/viewtopic.phtml?t=73470
http://www.oooforum.org/forum/viewtopic.phtml?t=26366
I think there is not such Step-By-Step post available who can direct openoffice users to configure with IIS and ASP.
Please Help, as its and urgent issue.
Thanking You,
Regards,
Verify if the App Pool assigned to your site or virtual directory has the "Enable 32 Bits Applications" parameter in True. Setting it to True was the solution to a similar problem a was facing some time ago.
Finally i found the answer by my self.
I have created a service in windows that calls star office document with administrative privileges.

ExportAsFixedFormat with Excel fails

I try to convert Excel files to PDF via COM automation. The code runs as a service using the system user. Unfortunately, I get the error "0x800A03EC" in the ExportAsFixedFormat() function. It works when I run this in an interactive session.
I've heard the systemprofile needs a Desktop folder, so I added those.
I've heard this also might have to do with the system user not having a default printer, so I added values to the following keys:
HKEY_USERS\S-1-5-18\Software\Microsoft\Windows NT\CurrentVersion\Devices
HKEY_USERS\S-1-5-18\Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts
But this only makes Excel hang instead of throwing an exception immediately.
I'm out of ideas and thankful for any help.
You have to select a default printer for this user. Try to import following code into your registry. Note: Replace these printers for your own (virtual) printers.
Windows Registry Editor Version 5.00
[HKEY_USERS\S-1-5-18\Software\Microsoft\Windows NT\CurrentVersion\Devices]
"Send To OneNote 2010"="winspool,nul:"
"Microsoft XPS Document Writer"="winspool,Ne00:"
[HKEY_USERS\S-1-5-18\Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts]
"Send To OneNote 2010"="winspool,nul:,15,45"
"Microsoft XPS Document Writer"="winspool,Ne00:,15,45"
[HKEY_USERS\S-1-5-18\Software\Microsoft\Windows NT\CurrentVersion\Windows]
"UserSelectedDefault"=dword:00000000
"Device"="Send To OneNote 2010,winspool,nul:"
Of course you still have to create your Desktop folder in
C:\Windows\SysWOW64\config\systemprofile
or in
C:\Windows\System32\config\systemprofile
depending on your setup.
After these steps you should be able to export Word, Powerpoint and Excel to PDF by using a regular, non-interactive service (e.g. Windows NT/SYSTEM user). You don't need any alterations in your Component Services
Wrong:
[HKEY_USERS\S-1-5-18\Software\Microsoft\Windows NT\CurrentVersion\Windows]
"UserSelectedDefault"=dword:00000000
"Device"="Send To OneNote 2010,winspool,nul:"
Correct:
[HKEY_USERS\S-1-5-18\Software\Microsoft\Windows NT\CurrentVersion\Windows]
"UserSelectedDefault"=dword:00000000
"Device"="Microsoft XPS Document Writer,winspool,Ne00:"
I struggled with this mightily and this post was so close. After trying a number of other things I knew this post was close and thought I'd try something.
For the record, the "Desktop" folder fix in systemprofile fixed this issue when we were running Windows Server 2008 R2 and Excel 2013 Automation. This only started being an issue for after we upgraded to Windows Server 2012 R2 and Excel 2016. To eliminate Excel as the culprit, I tried on a server with Windows Server 2012 R2 and Excel 2013 and experienced very similar issues.
All automation worked just fine under Network Service, but ideally, we wanted to run our site under ApplicationPoolIdentity.
First things first, the application pool running with ApplicationPoolIdentity needs to Load the User Profile.
Start Run -> inetmgr
expand Server -> Application Pools
right click on your App Pool -> Advanced Settings
under Process Model -> Load User Profile <-- should be set to true
So now I had to figure out who this identity was. Maybe there's a better way to do this, but since I added the user to IIS_IUSRS this is where I found the information.
Windows -> Edit local users and groups
Groups -> right click IIS_IUSRS -> Add to Group...
Add...
Locations... (choose local server), click OK
In the Enter the object names to select box type IIS APPPOOL\<app pool name>
(note the space and the triple P)
also, <app pool name> is the name of your Application Pool in inetmgr
Now you should see as a Member of IIS_IUSRS IIS APPPOOL\ (SID) where SID is your applicationpoolidentity security identifier in windows. This will be a very long alpha-numeric dashed string like "S-1-5-##-#########-#########-##########-#########-#########"
Unlike the answers above, this was the user I needed to edit in the registry.
So now following the above answers I had to add the following to the registry. Note: Adding the keys to S-1-5-18 did not solve the issue, I had to add them to the SID of the ApplicationPoolIdentity found above.
[HKU]\SID\Software\Microsoft\Windows NT\CurrentVersion\Devices
"Send To OneNote 2010"="winspool,nul:"
"Microsoft XPS Document Writer"="winspool,Ne00:"
[HKU]\SID\Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts
"Send To OneNote 2010"="winspool,nul:,15,45"
"Microsoft XPS Document Writer"="winspool,Ne00:,15,45"
[HKU]\SID\Software\Microsoft\Windows NT\CurrentVersion\Windows
"UserSelectedDefault"=dword:00000000
"Device"="Microsoft XPS Document Writer,winspool,Ne00:"
Notice how I used the "Correct" response from eletre/Robert. Using the OneNote option for Device did not work for me.
Hopefully this saves someone the trouble of hunting this down some day.

Error While creating SPSite instance with SharePoint Foundation 2010

I'm getting the following error while trying to create a SPSite instance (not open it, just create it):
"The Web application at <URL> could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application."
I have SharePoint Foundation 2010 installed on x64 Windows 7 laptop and VS 2008. I've done a lot of searching the last couple of days and I've tried any suggestion there is:
Setting user permissions to the database.
Targeting the application for x64 CPU.
Running my app with the sharepoint app pool account. Creating new app pool.
Creating windows forms and console applications to run the code from there.
Adding and removing the web application administrators.
Checked the logs (nothing in there).
Writing the URL in full, with machine name and with IP.
The funny thing is that the same code was working fine at one point and then just stopped. I cannot recall to have done anything special to damage it.
Any help will be much appreciated.
Regards,
Martin
To answer my own question the sharepoint site had to be on the default port - 80. Publishing it on any other port and trying to access it by putting the port in the URL did not work. Strange but it worked.

Sharepoint: Office Documents can only be uploaded; not opened and saved

I had two clients with a save issue in SharePoint.
When they try to save they would get a a very generic error: "Document Could not be saved"
The only way they could get them into SharePoint was by:
Saving to local File System
Using the Upload option from the SharePoint menu
Configurations
Client 1: Vista and Office 2007
Client 2: XP and Office 2003
I was able to fix client 1 by having him Map a Network Drive to the Sharepoint Site.
After mapping the network drive, somehow the OS magically knew about the SharePoint documents folder and he was able to save.
I'm not having the same luck with Client 2.
It won't even let me map the network drive. I get an error (one that I did not take a screenshot of and don't remember the exact wording...sorry). but it was an error trying to map the network drive to the SharePoint site.
So, after some Googling, I had him go to Windows Update and download all the latest patches for his OS.
He claims he did, but is still getting the problem.
Before I do another WebEx and start taking stabs in the dark to try and fix him, I was wondering if any veteran SharePoint users have run into this same issue and what they did to fix.
Or, is there some OS setting I should be looking at that needs to be toggled/modified.
I can access his SharePoint site just fine from several PCs and make modifications and save as necessary.
Did you try running the Microsoft Office Diagnostics?
Start --> Microsoft Office --> Microsoft Office Tools --> Microsoft Office Diagnostics
Let that scan and repair any issues it finds and see if that helps. That tool has fixed similar issues for me many times.

Resources