2011-06-20 19 views
1

こんにちは、ASP.NET 2.0 WebサイトのドメインでWindows NT認証を使用したいと思います。ASP.NET Webサイト2.0のドメインでのNT認証

初めて自分のWebサイトにアクセスしたときに、ユーザーの入力資格情報を強制します。 Webサイトはイントラネット上でのみ使用されます。

私はドメインがx.y.comの形式であることを知っています。

私は要素をweb.confingに追加:

  1. しかし、ユーザーがウェブを訪れたとき、私はどのようにclasic窓に入力されたユーザーの資格情報について formularを表示しない:

    <authentication mode="Windows"/> 
    

    私の最初の問題は、サイト。

私はこのフォーム意味:

http://blumenthalit.net/blog/Lists/Posts/Attachments/54/image_2.png

2そして、私の第二の問題は、ドメイン上の真偽です。私はそれをgoogleし、このパートコードだけが私のために働く。

public class WinAPI 
{ 
    // Use NTLM security provider to check 
    public const int LOGON32_PROVIDER_DEFAULT = 0x0; 
    // To validate the account 
    public const int LOGON32_LOGON_NETWORK = 0x3; 

    // API declaration for validating user credentials 
    [DllImport("advapi32.dll", SetLastError = true)] 
    public static extern bool LogonUser(string lpszUsername, string lpszDomain, 
     string lpszPassword, int dwLogonType, int dwLogonProvider, out int phToken); 
    //API to close the credential token 
    [DllImport("kernel32", EntryPoint = "CloseHandle")] 
    public static extern long CloseHandle(long hObject); 
}; 




    int hToken = 2; 
     bool ret = WinAPI.LogonUser("userName", "domain.example.com", "password", WinAPI.LOGON32_LOGON_NETWORK, 
     WinAPI.LOGON32_PROVIDER_DEFAULT, 
     out hToken); 

     if (ret == true) 
     { 
      MessageBox.Show(" Valid Windows domain User "); 
      WinAPI.CloseHandle(hToken); 
     } 
     else 
     { 
      MessageBox.Show(" Not an valid Windows domain User "); 
     } 

答えて

0

は、このリンクを読んで試してみてください、あなたがポップアップを取得する必要がありますので、それは、匿名ユーザーのアクセスを拒否する方法をあなたに教えてください。

http://weblogs.asp.net/scottgu/archive/2006/07/12/Recipe_3A00_-Enabling-Windows-Authentication-within-an-Intranet-ASP.NET-Web-application.aspx

<configuration> 
    <system.web> 
     <authentication mode="Windows" /> 
     <authorization> 
      <deny users="?"/> 
      </authorization> 
    </system.web> 
</configuration> 

Note that the <deny users=”?”/> directive within the <authorization> section above is what tells ASP.NET to deny access to the application to all “anonymous” users to the site (the “?” character means anonymous user). This forces Windows to authenticate the user, and ensures that the username is always available from code on the server. 
1

Windows認証の主なポイントは、ログインボックスがないを行うことを、イントラネットのために、あるユーザーが自分のドメインの資格情報を使用して自動的に認証し、表示されます。 SSL証明書をインストールし、手動で偽装しようとしない限り、ユーザーにユーザー名とパスワードの入力を強要したいのはなぜでしょうか?

IISでBasic Authenticationを有効にする方法は唯一の方法です(手順についてはIIS7/IIS6)。ただし、そうする場合は、通過中のユーザー名とパスワードを保護するためのSSL証明書が必要です。私はあなたがこのルートに行かないことを強くお勧めします。

1

@ blowdartさんの回答には、フォーム認証とLdapMembershipProviderを使用してActive Directoryに対して認証することもできます。

関連する問題