Leaderboard (728 x 90)
Showing posts with label IIS. Show all posts
Showing posts with label IIS. Show all posts

Tuesday, January 4, 2011

Windows x64 problem: The 'Microsoft.Jet.OLEDB. 4.0' provider is not registered on the local machine.

Cause:

There is no 64 bit version of Microsoft Jet OLE DB driver.

Resolution:

1. Install lastest service pack for windows

2. Force program to run as a 32 Bit application. In order to do this, you need utility found in .NET SDK named corflags.exe.

>> corflags program.exe /32BIT+

2. For run on IIS, you need to enable 32 bit applications on IIS

>> cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1

Thursday, October 21, 2010

How can I check the password of the IUSR and IWAM local accounts on a machine?

Usually the IUSR_ and IWAM_ passwords are set automatically and are never known. However, I've seen cases in which for some reason the passwords get out of sync or corrupted and need to be reset. The easiest way to reset these passwords is to extract the passwords that Microsoft IIS has in its metabase and update the accounts in Local Users and Groups to use that password.

You first need to update the adsutil.vbs script, which you'll find in the AdminScripts folder under the Inetpub folder, to display sensitive information (e.g., passwords) instead of just asterisks. Open the adsutil.vbs file in Notepad and search for the text "IsSecureProperty = True", replace this text with "IsSecureProperty = False" and save the file. Now run the following commands to return the passwords (/anonymoususerpass is the IUSR account; /wamuserpass is the IWAM_ account).

C:\Inetpub\AdminScripts>cscript adsutil.vbs get w3svc/anonymoususerpass

anonymoususerpass : (STRING) "/XEv`J01T"!69I"

C:\Inetpub\AdminScripts>cscript adsutil.vbs get w3svc/wamuserpass

wamuserpass : (STRING) "ikI37Q"W5\[,uu%"


If you want to reset the passwords to match the passwords you had already set in Local Users and Groups, use the following command:

C:\Inetpub\AdminScripts>cscript adsutil.vbs set w3svc/anonymoususerpass "Pa55word"

anonymoususerpass : (STRING) "Pa55word"

C:\Inetpub\AdminScripts>cscript adsutil.vbs set w3svc/wamuserpass "Pa55word"

wamuserpass : (STRING) "Pa55word"

You should now run the command below to sync the password from IIS with Microsoft Transaction Server (MTS) and component services:


C:\Inetpub\AdminScripts>cscript.exe synciwam.vbs -v

IIS Applications Defined:
Name, AppIsolated, Package ID

You should now restart IIS via the "All Tasks" context menu option of the IIS server in the MMC Internet Information Services (IIS) Manager snap-in.

Retrieve the IUSR (Anonymous) password using the IIS Resource Kit Metabase Explorer

Download and install the IIS Resource Kit and used it to retrieve the password of the IUSR account (IIS Anonymous User.)

After installing the IIS Resource Kit, follow these steps to retrieve the IUSR password using the Metabase Explorer:

  1. Open the IIS Metabase Explorer by going to Start > All Programs > IIS Resources > Metabase Explorer > Metabase Explorer
  2. Go to the "View" menu and click on "Secured Data" (this will make sure the password is not displayed as asterisks) and Inherited Data (this will display any data that the web site is inheriting from the default)
  3. Expand the W3SVC Branch
  4. Expand the Branch of an IIS site that is running anonymous access

    Note: To determine the ID of the IIS Site; select the "Web Sites" node in IIS and look for the Identifier column in the right pane.

  5. Select the "Root" node and look for the AnonymousUserPass property in the right pane.

Wednesday, August 4, 2010

How to list running application pool in IIS 6.0?

You can use the command-line script iisapp.vbs, which is stored in systemroot\system32, to view any worker processes that are currently running. This command is often used for troubleshooting.

The computer issuing the command must be running Windows XP or a member of the Windows Server 2003 family. The computer that the command affects must be running a member of the Windows Server 2003 family with IIS 6.0.

!!! Important

You must be a member of the Administrators group on the local computer to run scripts and executables. As a security best practice, log on to your computer by using an account that is not in the Administrators group, and then use the runas command to run your script or executable as an administrator. At a command prompt, type runas /profile /User:MyComputer\Administrator cmd to open a command window with administrator rights and then type cscript.exeScriptName (include the script's full path and any parameters).

This topic includes the following information:

Syntax: The order in which you must type a command and any arguments and options that follow it.

Parameters: The values that are given to variables in the command.

Examples: Sample code and an explanation of the results.

Syntax

iisapp [/a AppPoolName | /p PID]

Parameters

/aAppPoolName

Optional. Specifies the name of a particular application pool.

/pPID

Optional. Specifies an application pool by its ID number.

Examples

Example 1:

The following command displays all of the application pools that are running on the local computer:

iisapp

In response, iisapp displays all of the currently running applications, identifying each application pool by its process ID (PID) and application pool ID (AppPoolID). Iisapp omits all of the optional parameters and accepts the default values.

W3wp.exe PID: 2232 AppPoolID: DefaultAppPool

W3wp.exe PID: 2608 AppPoolID: MyAppPool

Example 2:

Use the following command to view a specific application by entering its PID:

iisapp /p 2608

In response, iisapp displays the specified application.

W3wp.exe PID: 2608 AppPoolID: MyAppPool

Monday, July 19, 2010

การตั้งค่า firewall สำหรับ Passive FTP Connection (ตอนที่ 2)

จากบทความในตอนที่ 1 หลายๆ คนคงจะพอเข้าใจกันแล้วว่าการเชื่อมต่อ FTP แบบ Passive Mode ทำงานอย่างไร และมีความจำเป็นสำหรับ client ที่ใช้งานอินเตอร์เน็ตผ่าน NAT, Firewall หรือ Router อย่างไร แต่สิ่งสำคัญที่จะลืมไปไม่ได้ คือ การเชื่อมต่อแบบนี้เซิร์ฟเวอร์จะต้องสุ่มหมายเลขพอร์ตที่อยู่ในช่วง 1024-65535 สำหรับใช้เป็นพอร์ตรับส่งข้อมูล และส่งหมายเลขพอร์ตดังกล่าวกลับไปยังไคลเอ็นต์ ประเด็นก็คือถ้าเราใช้ Windows Firewall หรือ Firewall ใดๆ ก็ตาม ในการป้องกันการโจมตีจากผู้บุกรุก เราจะต้องกำหนด policy อย่างไร เราจะต้อง allow พอร์ต 1024-65535 เพื่อให้ Passive FTP สามารถทำงานได้อย่างไม่มีปัญหาอย่างนั้นหรือ คำตอบนี้ถูกเพียงครึ่งเดียวครับ เพราะการทำแบบนั้น หมายความว่า คุณจะต้องลดระดับความปลอดภัยของเครื่องเซิร์ฟเวอร์ของคุณ เพียงเพื่อให้สามารถเชื่อมต่อ FTP แบบ Passive Mode ได้
วิธีการที่ดีกว่านั้น ก็คือ คุณสามารถกำหนดช่วงพอร์ต หรือ port range ที่จะใช้สำหรับการเชื่อมต่อ FTP แบบ passive mode
ซึ่งจะทำให้คุณสามารถควบคุมกฎเกณฑ์และนโยบายของไฟร์วอลล์ได้ง่ายขึ้น และปลอดภัยมากขึ้น

สำหรับ IIS6 + Microsoft FTP Service บน Windows 2003 Server

• ก่อนอื่น ต้อง Enable Direct Metabase Edit ใน Internet Information Service Manager
1. เปิด Internet Information Service Manager.
2. คลิกขวาบน โนดที่เป็นชื่อของเครื่องโลคอล
3. เลือก Properties.
4. ตรวจสอบให้แน่ใจว่าได้ทำเครื่องหมายในกล่องหน้าข้อความ Enable Direct Metabase Edit checkbox เรียบร้อยแล้ว

• คอนฟิก PassivePortRange โดยใช้ ADSUTIL script
1. เปิด Command Prompt
2. พิมพ์คำสั่ง cd C:\Inetpub\AdminScripts แล้วกดปุ่ม ENTER.
3. พิมพ์คำสั่ง cscript.exe adsutil.vbs set /MSFTPSVC/PassivePortRange "5001-5201"
4. Restart เซอร์วิสที่ชื่อว่า FTP Publishing Service.

• การ allow พอร์ตที่อยู่ในช่วงของ PassivePortRange ใน Windows Firewall
1. เปิด Command Prompt
2. สมมติว่าค่า PassivePortRange คือ 5001-5201 ให้พิมพ์คำสั่งต่อไปนี้
FOR /L %I IN (5001,1,5201) DO netsh firewall add portopening TCP %I "Passive FTP"%I

3. เสร็จสิ้นกระบวนการ ลองทดสอบการใช้งาน

การตั้งค่า firewall สำหรับ Passive FTP Connection (ตอนที่ 1)

FTP เป็นเซอร์วิสที่ทำงานบนโปรโตคอล TCP/IP ในการติดต่อและรับส่งข้อมูลกับ client โดยใช้พอร์ต 2 พอร์ต คือ พอร์ตรับคำสั่ง และพอร์ตข้อมูล โหมดของ FTP สามารถแบ่งออกเป็น 2 โหมด คือ Active Mode และ Passive Mode ซึ่งจะมีการทำงานที่แตกต่างกัน
รูปภาพ
ใน active mode ของ FTP ไคลเอ็นต์จะเชื่อมต่อจากพอร์ตแบบสุ่มที่มีค่าพอร์ตมากกว่า 1023 มาที่พอร์ต 21 ของเซิร์ฟเวอร์ ซึ่งเป็นพอร์ตรับคำสั่ง (พอร์ต N>1023 จากรูปจะสมมติให้ N=1026) แล้วส่งคำสั่งซึ่งจะบอกให้เซิร์ฟเวอร์ทราบหมายเลขพอร์ตที่จะใช้ในการรับส่งข้อมูลกับเครื่องไคลเอ็นต์ (พอร์ต N+1) จากนั้นเซิร์ฟเวอร์จะตอบสนองคำสั่งโดยจะส่ง acknowledge จากพอร์ต 21 กลับไปยังพอร์ต N ของเครื่องไคลเอ็นต์ แล้วจึงทำการเชื่อมต่อจากพอร์ต 20 ซึ่งเป็นพอร์ตข้อมูลของเซิร์ฟเวอร์ไปยังพอร์จ N+1 ของเครื่องไคลเอ็นต์ ในขั้นตอนท้ายสุด ไคลเอ็นต์จะตอบสนองการเชื่อมต่อจากเซิร์ฟเวอร์โดยจะส่ง acknowledge กลับไปยังพอร์ต 20 ของเครื่องเซิร์ฟเวอร์ คำสั่งจากเครื่องไคลเอ็นต์จะส่งไปที่พอร์ต 21 ของเครื่องเซิร์ฟเวอร์ และเซิร์ฟเวอร์จะรับส่งข้อมูลกับเครื่องไคลเอ็นต์ผ่านทางพอร์ต 20

ปัญหาหลักของการทำงานในโหมดนี้ ก็คือ เครื่องไคลเอ็นต์ที่ติดตั้งไฟร์วอลล์ไว้ อาจจะไม่สามารถใช้งานได้ เนื่องจากเซิร์ฟเวอร์จะส่งข้อมูลจากพอร์ต 20 กลับไปที่พอร์ต N+1 ซึ่งพอร์ตดังกล่าวเป็นแบบสุ่ม ซึ่งโดยทั่วไปมักจะบล็อคไว้
วิธีแก้ไข คือจะต้อง allow packet ทั้งหมดที่มาจากพอร์ต 20 ของเครื่องภายนอก แต่วิธีนี้ก็อาจทำให้เกิดผลกระทบต่อความปลอดภัยภายในองค์กรอีกเช่นเดียวกัน

เพื่อแก้ปัญหาดังกล่าว จึงมีการพัฒนารูปแบบการเชื่อมต่อของ FTP ขึ้นมาอีกแบบหนึ่งซึ่งเรียกว่า Passive Mode

หลักการทำงานในโหมดนี้ ก็คือ
รูปภาพ
การทำงานในโหมดนี้จะเริ่มจากไคลเอ็นต์เชื่อมต่อจากพอร์ตแบบสุ่ม N>1023 ไปที่พอร์ต 21 ของเครื่องเซิร์ฟเวอร์ และส่งคำสั่ง PASV ไปที่เซิร์ฟเวอร์
เมื่อเซิร์ฟเวอร์ได้รับคำสั่งจะสุ่มพอร์ตสำหรับใช้เป็นพอร์ตข้อมูล สมมติให้เป็นพอร์ต P>1023 จากรูป พอร์ต P=2024 จากนั้นเซิร์ฟเวอร์จะส่งหมายเลขพอร์ต P ดังกล่าวกลับไปที่พอร์ต N ของเครื่องไคลเอ็นต์
เมื่อเครื่องไคลเอ็นต์รับทราบ ไคลเอ็นต์จะเชื่อมต่อจากพอร์ต N+1 ไปที่พอร์ต P ของเครื่องเซิร์ฟเวอร์ จากนั้นเซิร์ฟเวอร์จะส่ง Acknowledge กลับไปยังพอร์ต N+1 ของเครื่องไคลเอ็นต์ คำสั่งจากเครื่องไคลเอ็นต์จะส่งไปที่พอร์ต 21 ของเครื่องเซิร์ฟเวอร์ และเซิร์ฟเวอร์จะรับส่งข้อมูลกับไคลเอ็นต์ผ่่านทางพอร์ต P ที่เซิร์ฟเวอร์สุ่มขึ้นมา

ถึงตรงนี้ ก็คงจะเห็นภาพกันแล้วว่าใน Passive Mode การเชื่อมต่อจะเริ่มจาก client ก่อนเสมอ จึงขจัดปัญหาเรื่องไฟร์วอลล์ในส่วนของไคลเอ็นต์ไป แต่คำถามต่อมาก็คือ แล้วเซิร์ฟเวอร์ล่ะ จะควบคุมนโยบายและกฎเกณฑ์ต่างๆ ของไฟร์วอลล์ได้อย่างไร ในเมื่อพอร์ตที่ใช้เป็นพอร์ตข้อมูลเป็นพอร์ตแบบสุ่มซึ่งมากกว่า 1023 แต่เป็นพอร์ตอะไรก็ได้ จะต้อง allow ทุกพอร์ตที่มีค่ามากกว่า 1023 เลยอย่างนั้นหรือ
คำตอบ คือ ไม่จำเป็นครับ เพราะ FTP Server แต่ละค่าย ก็จะมีวิธีในการกำหนด port range ที่จะใช้ในการสุ่มเป็นพอร์ตข้อมูลในการทำงานแบบ Passive Mode อยู่แล้ว แต่วิธีการก็จะแตกต่างกันไป ตามแต่ละค่าย ทีนี้เราก็แค่ allow เฉพาะพอร์ตที่อยู่ใน port range ที่เรากำหนดไว้เท่านั้น

ตอนต่อไปจะกล่าวถึงวิธีการตั้งค่าไฟร์วอลล์สำหรับการทำงานในโหมด Passive FTP สำหรับ Microsoft FTP Service

Tuesday, January 19, 2010

How to setup a website to access content on a remote NAS server

One of the more common questions in the newsgroups. "How can I have my content on a remote server vs. the local web server?". This article is a step by step how-to serve content from a remote server. This article assumes there are two machines, 1 web server and 1 content server. Lets get started.

Assumptions

  • Two servers running Windows 2003
  • Local user id on each machine with the same user id with same password

Setting up environment.

  • Create a user called RemoteContentUser and password PA$$@Word! on both machines
  • Create a folder on the server acting as the remote nas server called RemoteContent
  • Create a website on your web server, point the website to your remote share.
  • Set the User id and Password on the virtual directory as the same as the local user id you created.

Creating the local user id that will be used to authenticate to the remote share. You could also create using Computer Management MMC.

  • Create user on web server.

  • Create user on remote machine.

  • Create RemoteContent$ Share (This allows access directly to the content using a UNC Path)

  • Using CACLS to grant the RemoteContentUser 'READ' permissions on the content folder

  • Screen shot from Windows Explorer showing the NTFS permissions.

  • Change directory to C:\RemoteContent
  • Create sample Default.asp that will be displayed from the web server.
  • Create sample Default.aspx that will be displayed from web server
  • Use the ECHO command to create the Default.asp and Default.aspx adding some sample content

Setup the WebSite

  • Open Internet Information Services Manager

  • Right Click on Web Sites and Select a New Web Site

  • Click Next
  • Enter your domain name.
  • Click Next

  • Uncheck "Always use the authenticated users credentials when validating access to the network directory"
  • Click Next

  • Type in local user name, for our article this is RemoteContentUser and "PA$$@Word!"
  • Confirm password

  • Click OK
  • Click Next
  • Select READ, Run Scripts (such as ASP)
  • Click Next

  • Click Finish

  • Notice the Default.asp, Default.aspx page displayed in the right pane.

  • Browse the Classic Default.asp webpage

To run ASPX webpages you'll need to ensure the local user has MODIFY permission to the temporary folder where .NET pages are compiled. If you do not, you could get this error listed below.

  • Grant local RemoteContentUser 'CHANGE' permissions on the temporary folder where ASP.NET pages are compiled. This can be any user, we are just using a local user for an example. Security should be kept in mind when setting up your environment.
  • Here is the command cacls "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files" /T /E /G remotecontentuser:C

  • Browse the Default.aspx webpages.

If you continue to have issues executing ASP.NET webpages. You probably need to grant CASPOL permissions. The command is listed below.

CASPOL

Here is a sample error when executing ASP.NET content on a remote share.

System.Security.SecurityException: Security error.

Source Error:

Line 57: private static System.Collections.ArrayList
__fileDependencies;
Line 58:
Line 59: public Default_aspx() {
Line 60: System.Collections.ArrayList dependencies;
Line 61: if ((ASP.Default_aspx.__intialized == false)) {


Source File: D:\ASPNetTemp\authors_gfweis\3070428c\5b9f07db\9nidezwv.0.cs
Line: 59

Stack Trace:

[SecurityException: Security error.]
GfWeis._Default..ctor() +0
ASP.Default_aspx..ctor() in
D:\ASPNetTemp\authors_gfweis\3070428c\5b9f07db\9nidezwv.0.cs:59

CASPOL to the Rescue

What is CASPOL? This is a command line utility to adjust the security on the CLR and .NET framework. There is also two MMC's under the Administrative Tools to help adjust the CAS settings. In order to see all the settings CASPOL can do, open a command prompt and type in CASPOL /? Be very careful before adjusting these settings. This shouldn't be done on your production server without first testing on development server. Here is more information on MSDN about CASPOL as well as many other tools provided by the .NET framework. Code Access Security Policy Tool (Caspol.exe) (Allows you to examine and modify machine, user, and enterprise-level code access security policies.)

Here is the command that did the trick!

caspol -m -ag 1 -url "file://\\ServerName\RemoteContent$\*" FullTrust -exclusive on

Here is a couple of troubleshooting command line items used.

  • caspol -s off //This turns off CAS security
  • caspol -s on //This turns on CAS Security
  • caspol -rs //Resets CAS security.

In conclusion, this is just one example of how to setup a website to access content on a remote server. We would suggest setting up a test environment so you understand the settings before implementing into a production environment. We used a local user on both servers, if you have a Active Directory Domain available you could use a Domain user vs. a local user.


Reference: http://www.iislogs.com/articles/23/