ICredentials.GetCredential メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ICredentials.GetCredential メソッドの意味・解説 

ICredentials.GetCredential メソッド

指定した URI および認証種類関連付けられている NetworkCredential オブジェクト返します

名前空間: System.Net
アセンブリ: System (system.dll 内)
構文構文

Function GetCredential ( _
    uri As Uri, _
    authType As String _
) As NetworkCredential
Dim instance As ICredentials
Dim uri As Uri
Dim authType As String
Dim returnValue As NetworkCredential

returnValue = instance.GetCredential(uri, authType)
NetworkCredential GetCredential (
    Uri uri,
    string authType
)
NetworkCredential^ GetCredential (
    Uri^ uri, 
    String^ authType
)
NetworkCredential GetCredential (
    Uri uri, 
    String authType
)
function GetCredential (
    uri : Uri, 
    authType : String
) : NetworkCredential

パラメータ

uri

クライアント認証提供している Uri

authType

IAuthenticationModule.AuthenticationType プロパティ定義される認証種類

戻り値
指定した URI および認証種類関連付けられている NetworkCredential資格情報使用できない場合null 参照 (Visual Basic では Nothing)。

解説解説
使用例使用例

GetCredential使用してNetworkCredential インスタンス取得する例を次に示します

       
Class CredentialInfo
    Public uriObj As Uri
    Public authenticationType As [String]
    Public networkCredentialObj As NetworkCredential
    
    
    Public Sub New(uriObj
 As Uri, authenticationType As [String], networkCredentialObj
 As NetworkCredential)
        Me.uriObj = uriObj
        Me.authenticationType = authenticationType
        Me.networkCredentialObj = networkCredentialObj
    End Sub 'New
End Class 'CredentialInfo

Private arrayListObj As ArrayList


Public Sub New()
    arrayListObj = New ArrayList()
End Sub 'New


Public Sub Add(uriObj As
 Uri, authenticationType As [String], credential As
 NetworkCredential)
    ' adds a 'CredentialInfo' object into a list
    arrayListObj.Add(New CredentialInfo(uriObj, authenticationType,
 credential))
End Sub 'Add

' Remove the 'CredentialInfo' object from the list which matches to
 the given 'Uri' and 'AuthenticationType'
Public Sub Remove(uriObj As
 Uri, authenticationType As [String])
    Dim index As Integer
    For index = 0 To arrayListObj.Count - 1
        Dim credentialInfo As CredentialInfo
 = CType(arrayListObj(index), CredentialInfo)
        If uriObj.Equals(credentialInfo.uriObj) And
 authenticationType.Equals(credentialInfo.authenticationType) Then
            arrayListObj.RemoveAt(index)
        End If
    Next index
End Sub 'Remove

Public Function GetCredential(uriObj As
 Uri, authenticationType As [String]) As NetworkCredential
  Implements ICredentials.GetCredential
    Dim index As Integer
    For index = 0 To arrayListObj.Count - 1
        Dim credentialInfoObj As CredentialInfo
 = CType(arrayListObj(index), CredentialInfo)
        If uriObj.Equals(credentialInfoObj.uriObj) And
 authenticationType.Equals(credentialInfoObj.authenticationType) Then
            Return credentialInfoObj.networkCredentialObj
        End If
    Next index
    Return Nothing
End Function 'GetCredential
class CredentialList : ICredentials
{
    class CredentialInfo
    {
        public Uri uriObj;
        public String authenticationType;
        public NetworkCredential networkCredentialObj;
  
        public CredentialInfo(Uri uriObj, String authenticationType,
 NetworkCredential networkCredentialObj)
        {
            this.uriObj = uriObj;
            this.authenticationType = authenticationType;
            this.networkCredentialObj = networkCredentialObj;
        }
    }

    private ArrayList arrayListObj;

    public CredentialList()
    {
        arrayListObj = new ArrayList();
    }

    public void Add (Uri uriObj, String authenticationType,
 NetworkCredential credential)
    {
        // Add a 'CredentialInfo' object into a list.
        arrayListObj.Add (new CredentialInfo(uriObj, authenticationType,
 credential));      
    }
    // Remove the 'CredentialInfo' object from the list that matches
 to the given 'Uri' and 'AuthenticationType'
    public void Remove (Uri uriObj, String
 authenticationType)
    {
        for(int index=0;index < arrayListObj.Count;
 index++)
        {
            CredentialInfo credentialInfo = (CredentialInfo)arrayListObj[index];
            if(uriObj.Equals(credentialInfo.uriObj)&&
 authenticationType.Equals(credentialInfo.authenticationType))
                arrayListObj.RemoveAt(index);
        }
    }
    public NetworkCredential GetCredential (Uri uriObj, String
 authenticationType)
    {
        for(int index=0;index < arrayListObj.Count;
 index++)
        {
            CredentialInfo credentialInfoObj = (CredentialInfo)arrayListObj[index];
            if(uriObj.Equals(credentialInfoObj.uriObj) &&
 authenticationType.Equals(credentialInfoObj.authenticationType))
                return credentialInfoObj.networkCredentialObj;
        }
        return null;
    }
};
ref class CredentialList: public ICredentials
{
private:
   ref class CredentialInfo
   {
   public:
      Uri^ uriObj;
      String^ authenticationType;
      NetworkCredential^ networkCredentialObj;
      CredentialInfo( Uri^ uriObj, String^ authenticationType, NetworkCredential^
 networkCredentialObj )
      {
         this->uriObj = uriObj;
         this->authenticationType = authenticationType;
         this->networkCredentialObj = networkCredentialObj;
      }
   };

   ArrayList^ arrayListObj;

public:
   CredentialList()
   {
      arrayListObj = gcnew ArrayList;
   }

   void Add( Uri^ uriObj, String^ authenticationType, NetworkCredential^
 credential )
   {
      
      // Add a 'CredentialInfo' object into a list.
      arrayListObj->Add( gcnew CredentialInfo( uriObj,authenticationType,credential
 ) );
   }

   // Remove the 'CredentialInfo' object from the list that matches
 to the given 'Uri' and 'AuthenticationType'
   void Remove( Uri^ uriObj, String^ authenticationType )
   {
      for ( int index = 0; index < arrayListObj->Count;
 index++ )
      {
         CredentialInfo^ credentialInfo = dynamic_cast<CredentialInfo^>(arrayListObj[
 index ]);
         if ( uriObj->Equals( credentialInfo->uriObj ) &&
 authenticationType->Equals( credentialInfo->authenticationType ) )
                  arrayListObj->RemoveAt( index );
      }
   }

   virtual NetworkCredential^ GetCredential( Uri^ uriObj, String^ authenticationType
 )
   {
      for ( int index = 0; index < arrayListObj->Count;
 index++ )
      {
         CredentialInfo^ credentialInfoObj = dynamic_cast<CredentialInfo^>(arrayListObj[
 index ]);
         if ( uriObj->Equals( credentialInfoObj->uriObj
 ) && authenticationType->Equals( credentialInfoObj->authenticationType
 ) )
                  return credentialInfoObj->networkCredentialObj;
      }
      return nullptr;
   }
};
class CredentialList implements ICredentials
{
    class CredentialInfo
    {
        public Uri uriObj;
        public String authenticationType;
        public NetworkCredential networkCredentialObj;

        public CredentialInfo(Uri uriObj, String authenticationType,
 
            NetworkCredential networkCredentialObj)
        {
            this.uriObj = uriObj;
            this.authenticationType = authenticationType;
            this.networkCredentialObj = networkCredentialObj;
        } //CredentialInfo
    } //CredentialInfo

    private ArrayList arrayListObj;

    public CredentialList()
    {
        arrayListObj = new ArrayList();
    } //CredentialList

    public void Add(Uri uriObj, String authenticationType,
 
        NetworkCredential credential)
    {
        // Add a 'CredentialInfo' object into a list.
        arrayListObj.Add(new CredentialInfo(uriObj, 
            authenticationType, credential));
    } //Add

    // Remove the 'CredentialInfo' object from the list that matches
 to 
    // the given 'Uri' and 'AuthenticationType'
    public void Remove(Uri uriObj, String authenticationType)
    {
        for (int index = 0; index < arrayListObj.get_Count();
 index++) {
            CredentialInfo credentialInfo = (CredentialInfo)
                arrayListObj.get_Item(index);

            if (uriObj.Equals(credentialInfo.uriObj) &&
 
                authenticationType.Equals(credentialInfo.authenticationType)) {
                arrayListObj.RemoveAt(index);
            }
        }
    } //Remove

    public NetworkCredential GetCredential(Uri uriObj, 
        String authenticationType)
    {
        for (int index = 0; index < arrayListObj.get_Count();
 index++) {
            CredentialInfo credentialInfoObj = (CredentialInfo)
                arrayListObj.get_Item(index);

            if (uriObj.Equals(credentialInfoObj.uriObj) &&
 
                authenticationType.Equals(credentialInfoObj.
                authenticationType)) {
                return credentialInfoObj.networkCredentialObj;
            }
        }
        return null;
    } //GetCredential
} //CredentialList
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からICredentials.GetCredential メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からICredentials.GetCredential メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からICredentials.GetCredential メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ICredentials.GetCredential メソッド」の関連用語

ICredentials.GetCredential メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ICredentials.GetCredential メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS