ASP.NET operates on Word's IIS permission Settings

  • 2020-05-10 18:03:27
  • OfStack

The ASP.NET account has no permission to operate the Microsoft Office object by default. If the permission is not configured, the code will throw an exception similar to the following:

Failed to retrieve the component in the COM class factory where CLSID is {00024500-0000-0000-C000-000000000046} due to the following error: 80070005.

This makes it difficult for Asp.NET to manipulate Microsoft Office objects. But we still have to find a way to manipulate the Office object. The following is a brief introduction to the methods I have used in the development process:

Method 1: configure the Web.Config file to simulate the account of the local system on each request.

Specific operation: add the following node in the Web.Config file:

< identity impersonate="true" userName="accountname" password="password" / >
Where: userName is the local account to be simulated, and password is the password of the account.

Method 2: in the "DCOM configuration", configure the permissions for the IIS account to operate Word (the other Office objects are also 1).

How to do it: "component services (Component Service)" - > Computer (Computers) - > My computer (My Computer) - > DCOM configuration (DCOM Config) - > Microsoft Office Word 97-2003 document, right click "Microsoft Office Word Word 97-2003 document", select "properties" and proceed to the next two steps:

(1) on the [id (Identity)] TAB, select "interactive user (The interactive user)".

(Security)] (2) in the security TAB, respectively to the first two group (start and activate the permissions, access) choose "custom (customer)", then click "edit", add in the pop-up screen IIS account (generally Server version of the operating system for NETWORK SERVICES, other system (XP) could be ASP. NET), and in the following permissions box, allocated all permissions to the user.

Method 3: assign local accounts to the application pool for the ASP.NET site

How to do this: in IIS, create a new application pool for the ASP.NET site, change the identity (identity) TAB of the application pool properties, and select "local system (LocalSystem)" for the "predefined account".

If it is in IIS7.0, follow these steps: create a new application pool for the ASP.NET site. Select the application pool, advanced Settings - > Process mode -- > Logo: select localSystem.

Of the above three methods, I prefer to use the third method because I need to close the Word object process after manipulating the Word object, while the third method can give the ASP.NET application permission to terminate the word process without any other Settings.

Related articles: