23.2.2.3. Register the Web Part as Safe
Next you need to register the Web Part you’re going to use
as a safe control. This allows it to run
without needing an elevated prompt. To register the Web Part,
follow these steps:
Open an elevated Cmd or PowerShell command prompt using
Run As Administrator.
Change to the directory where the configuration file for
Companyweb is, and open web.config in Notepad or
your favorite plain-text editor as shown in Figure 19 by
entering the following commands:
cd "C:\inetpub\wwwroot\wss\VirtualDirectories\Companyweb80"
notepad web.config
In the web.config file, locate the <SafeControls>
section of the file. At the end of the section of SafeControl
Assembly entries, add the following line:
<SafeControl Assembly="TSPortalWebPart, Version=6.1.0.0, Culture=neutral,PublicKe
yToken=31bf3856ad364e35" Namespace="Microsoft.TerminalServices.Publishing.Portal"
TypeName="*" Safe="True" AllowRemoteDesigner="True" />
Note:
Add this as a single line, with no line breaks.
Save the change and exit Notepad. Keep the elevated
command prompt open. You’ll need it in the next
section.
Warning:
IMPORTANT Always make a
copy of important files before editing them—just in case.
2.4. Create a Folder to Store the Web Part
Next you need to create a folder to hold the Web Part and
its images, and to give the Network Services account full control
on the folder. Use the following steps:
In the elevated command prompt from the previous
section, type the following commands:
mkdir "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\
wpresources\TSPortalWebPart\6.1.0.0__31bf3856ad364e35\images"
mkdir "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\
wpresources\TSPortalWebPart\6.1.0.0__31bf3856ad364e35\rdp"
Note:
Notice the two underscores after 6.1.0.0 in the
preceding command lines.
Change the directory to the parent folder of the two folders you just
created:
cd "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\
wpresources\TSPortalWebPart\6.1.0.0__31bf3856ad364e35"
Give the Network Service account and the spwebapp
account full control over the two folders you created in step
1:
cmd /c icacls images /grant NetworkService:F
cmd /c icacls images /grant spwebapp:F
cmd /c icacls rdp /grant NetworkService:F
cmd /c icacls rdp /grant spwebapp:F
Close the Command Prompt window if you see a success
message.