OracleConnectionStringBuilder.IntegratedSecurity Propriété

Définition

Obtient ou définit une valeur qui indique si "User ID" et "Password" sont spécifiés dans la connexion (valeur false) ou si les informations actuelles d'identification du compte Windows sont utilisées pour l'authentification (valeur true).

public:
 property bool IntegratedSecurity { bool get(); void set(bool value); };
public bool IntegratedSecurity { get; set; }
member this.IntegratedSecurity : bool with get, set
Public Property IntegratedSecurity As Boolean

Valeur de propriété

Valeur de la propriété IntegratedSecurity, ou false si aucune n'a été fournie.

Exemples

L'exemple suivant convertit une chaîne de connexion existante qui utilise l'authentification Windows en une chaîne de connexion qui utilise la sécurité intégrée. Pour cela, l'exemple supprime le nom d'utilisateur et le mot de passe de la chaîne de connexion, puis définit la propriété IntegratedSecurity de l'objet OracleConnectionStringBuilder.

Notes

Cet exemple inclut un mot de passe pour illustrer l'utilisation de OracleConnectionStringBuilder avec les chaînes de connexion. Dans vos applications, nous vous recommandons d'utiliser l'authentification Windows. Si vous devez utiliser un mot de passe, n'incluez pas de mot de passe codé en dur dans votre application.

// You may need to set a reference to the System.Data.OracleClient
// assembly before you can run this sample.
using System.Data.OracleClient;

class Program
{
    static void Main()
    {
        try
        {
            string connectString =
                "Data Source=OracleSample;User ID=Mary;Password=*****;";

            OracleConnectionStringBuilder builder =
                new OracleConnectionStringBuilder(connectString);
            Console.WriteLine("Original: " + builder.ConnectionString);

            // Use the Remove method
            // in order to reset the user ID and password back to their
            // default (empty string) values. Simply setting the
            // associated property values to an empty string will not
            // remove them from the connection string; you must
            // call the Remove method.
            builder.Remove("User ID");
            builder.Remove("Password");

            // Turn on integrated security.
            builder.IntegratedSecurity = true;

            Console.WriteLine("Modified: " + builder.ConnectionString);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

        Console.WriteLine("Press any key to finish.");
        Console.ReadLine();
    }
}
' You may need to set a reference to the System.Data.OracleClient
' assembly before you can run this example. 
Imports System.Data.OracleClient

Module Module1

  Sub Main()
    Try
      Dim connectString As String = _
       "Data Source=OracleSample;User ID=Mary;Password=*****;"

      Dim builder As New OracleConnectionStringBuilder(connectString)
      Console.WriteLine("Original: " & builder.ConnectionString)

      ' Use the Remove method
      ' in order to reset the user ID and password back to their
      ' default (empty string) values. Simply setting the 
      ' associated property values to an empty string will not
      ' remove them from the connection string; you must
      ' call the Remove method.
      builder.Remove("User ID")
      builder.Remove("Password")

      ' Turn on integrated security.
      builder.IntegratedSecurity = True

      Console.WriteLine("Modified: " & builder.ConnectionString)

    Catch ex As Exception
      Console.WriteLine(ex.Message)
    End Try

    Console.WriteLine("Press any key to finish.")
    Console.ReadLine()
  End Sub
End Module

Remarques

Cette propriété correspond à la clé « Sécurité intégrée » dans le chaîne de connexion.

S’applique à

Voir aussi