NetworkCredential コンストラクタ (String, String)
アセンブリ: System (system.dll 内)
構文
Dim userName As String Dim password As String Dim instance As New NetworkCredential(userName, password)
コンストラクタは、UserName プロパティを userName に設定し、Password プロパティを password に設定して、NetworkCredential オブジェクトを初期化します。
指定したユーザー名とパスワードを使用して、NetworkCredential オブジェクトを作成するコード例を次に示します。
' Call the constructor to create an instance of NetworkCredential with the ' specified user name and password. Dim myCredentials As New NetworkCredential(username, passwd) ' Create a WebRequest with the specified URL. Dim myWebRequest As WebRequest = WebRequest.Create(url) myCredentials.Domain = domain myWebRequest.Credentials = myCredentials Console.WriteLine(ControlChars.Cr + ControlChars.Cr + "Credentials Domain : {0} , UserName : {1} , Password : {2}", myCredentials.Domain, myCredentials.UserName, myCredentials.Password) Console.WriteLine(ControlChars.Cr + ControlChars.Cr + "Request to Url is sent.Waiting for response...") ' Send the request and wait for a response. Dim myWebResponse As WebResponse = myWebRequest.GetResponse() ' Process the response. Console.WriteLine(ControlChars.Cr + "Response received successfully.") ' Release the resources of the response object. myWebResponse.Close()
// Call the onstructor to create an instance of NetworkCredential with the // specified user name and password. NetworkCredential myCredentials = new NetworkCredential(username ,passwd); // Create a WebRequest with the specified URL. WebRequest myWebRequest = WebRequest.Create(url); myCredentials.Domain = domain; myWebRequest.Credentials = myCredentials; Console.WriteLine("\n\nCredentials Domain : {0} , UserName : {1} , Password : {2}", myCredentials.Domain, myCredentials.UserName, myCredentials.Password); Console.WriteLine("\n\nRequest to Url is sent.Waiting for response..."); // Send the request and wait for a response. WebResponse myWebResponse = myWebRequest.GetResponse(); // Process the response. Console.WriteLine("\nResponse received successfully."); // Release the resources of the response object. myWebResponse.Close();
// Call the onstructor to create an instance of NetworkCredential with the // specified user name and password. NetworkCredential^ myCredentials = gcnew NetworkCredential( username,passwd ); // Create a WebRequest with the specified URL. WebRequest^ myWebRequest = WebRequest::Create( url ); myCredentials->Domain = domain; myWebRequest->Credentials = myCredentials; Console::WriteLine( "\n\nCredentials Domain : {0} , UserName : {1} , Password : {2}", myCredentials->Domain, myCredentials->UserName, myCredentials->Password ); Console::WriteLine( "\n\nRequest to Url is sent.Waiting for response..." ); // Send the request and wait for a response. WebResponse^ myWebResponse = myWebRequest->GetResponse(); // Process the response. Console::WriteLine( "\nResponse received successfully." ); // Release the resources of the response object. myWebResponse->Close();
// Call the onstructor to create an instance of // NetworkCredential with the // specified user name and password. NetworkCredential myCredentials = new NetworkCredential(userName , passwd); // Create a WebRequest with the specified URL. WebRequest myWebRequest = WebRequest.Create(url); myCredentials.set_Domain(domain); myWebRequest.set_Credentials(myCredentials); Console.WriteLine("\n\nCredentials Domain : {0} , UserName : " + "{1} , Password : {2}", myCredentials.get_Domain(), myCredentials.get_UserName(), myCredentials.get_Password()); Console.WriteLine("\n\nRequest to Url is sent.Waiting for " + "response..."); // Send the request and wait for a response. WebResponse myWebResponse = myWebRequest.GetResponse(); // Process the response. Console.WriteLine("\nResponse received successfully."); // Release the resources of the response object. myWebResponse.Close();
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
NetworkCredential コンストラクタ (String, String, String)
アセンブリ: System (system.dll 内)
構文
Dim userName As String Dim password As String Dim domain As String Dim instance As New NetworkCredential(userName, password, domain)
コンストラクタは UserName プロパティを userName に、Password プロパティを password に、および Domain プロパティを domain に設定して、NetworkCredential オブジェクトを初期化します。
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
NetworkCredential コンストラクタ
オーバーロードの一覧
名前 | 説明 |
---|---|
NetworkCredential () | NetworkCredential クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |
NetworkCredential (String, String) | 指定したユーザー名とパスワードを使用して、NetworkCredential クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |
NetworkCredential (String, String, String) | 指定したユーザー名、パスワード、およびドメインを使用して、NetworkCredential クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |
NetworkCredential コンストラクタ ()
アセンブリ: System (system.dll 内)
構文
解説
プラットフォーム
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- NetworkCredential コンストラクタのページへのリンク