Partager via


XmlSecureResolver.Credentials Propriété

Définition

Définit les informations d'identification utilisées pour authentifier les demandes web.

public:
 virtual property System::Net::ICredentials ^ Credentials {  void set(System::Net::ICredentials ^ value); };
public override System.Net.ICredentials Credentials { set; }
member this.Credentials : System.Net.ICredentials
Public Overrides Property Credentials As ICredentials

Valeur de propriété

ICredentials

Informations d'identification à utiliser pour authentifier les demandes web. Le XmlSecureResolver définit les informations d'identification fournies sur le XmlResolver sous-jacent. Si cette propriété n'est pas définie, la valeur par défaut est null ; XmlSecureResolver n'a donc pas d'informations d'identification d'utilisateur.

Exemples

L’exemple suivant utilise une XmlSecureResolver avec les informations d’identification par défaut pour résoudre et ouvrir les ressources réseau nécessaires par le XmlTextReader.

#using <System.dll>
#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
using namespace System::Net;
int main()
{
   
   // Create the reader.
   XmlTextReader^ reader = gcnew XmlTextReader( "http://myServer/data/books.xml" );
   
   // Create a secure resolver with default credentials.
   XmlUrlResolver^ resolver = gcnew XmlUrlResolver;
   XmlSecureResolver^ sResolver = gcnew XmlSecureResolver( resolver,"http://myServer/data/" );
   sResolver->Credentials = CredentialCache::DefaultCredentials;
   
   // Use the secure resolver to resolve resources.
   reader->XmlResolver = sResolver;
   
   // Parse the file.
   while ( reader->Read() )
   {
      
      // Do any additional processing here.
   }

   
   // Close the reader.
   reader->Close();
}
using System;
using System.IO;
using System.Xml;
using System.Net;

public class Sample {

  public static void Main() {

    // Create the reader.
    XmlTextReader reader = new XmlTextReader("http://myServer/data/books.xml");

    // Create a secure resolver with default credentials.
    XmlUrlResolver resolver = new XmlUrlResolver();
    XmlSecureResolver sResolver = new XmlSecureResolver(resolver, "http://myServer/data/");
    sResolver.Credentials = CredentialCache.DefaultCredentials;

    // Use the secure resolver to resolve resources.
    reader.XmlResolver = sResolver;

    // Parse the file.
    while (reader.Read()) {
       // Do any additional processing here.
    }

    // Close the reader.
    reader.Close();
  }
}
Imports System.IO
Imports System.Xml
Imports System.Net

public class Sample 

  public shared sub Main() 

    ' Create the reader.
    Dim reader as XmlTextReader = new XmlTextReader("http://myServer/data/books.xml")
   
    ' Create a secure resolver with default credentials.
    Dim resolver as XmlUrlResolver = new XmlUrlResolver()
    Dim sResolver as XmlSecureResolver = new XmlSecureResolver(resolver, "http://myServer/data/")
    sResolver.Credentials = CredentialCache.DefaultCredentials

    ' Use the secure resolver to resolve resources.
    reader.XmlResolver = sResolver

    ' Parse the file.
    while (reader.Read()) 
       ' Do any additional processing here.
    end while           
  
    ' Close the reader.
    reader.Close()     
  
  end sub
end class

S’applique à

Voir aussi