VintaSoft Imaging .NET SDK 14.0: Документация для .NET разработчика
Vintasoft.Imaging.Pdf Namespace / PdfDocument Class / Authenticate(String) Method
Синтаксис Example Требования Смотрите также
В этом разделе
    Authenticate(String) Метод (PdfDocument)
    В этом разделе
    Выполняет аутентификацию с использованием указанного пароля.
    Синтаксис
    'Declaration
    
    Public Function Authenticate( _
    ByVal password
    Пароль пользователя или владельца.
    As System.String _
    ) As Vintasoft.Imaging.Pdf.Security.AuthorizationResult
    public Vintasoft.Imaging.Pdf.Security.AuthorizationResult Authenticate(
    System.String password
    )
    public: Vintasoft.Imaging.Pdf.Security.AuthorizationResult Authenticate(
    System.String password
    )
    public:
    Vintasoft.Imaging.Pdf.Security.AuthorizationResult Authenticate(
    System.String password
    )

    Parameters

    password
    Пароль пользователя или владельца.

    Return Value

    Результат аутентификации.
    Пример

    
    Public Shared Sub DocumentAuthentication(document As Vintasoft.Imaging.Pdf.PdfDocument, password As String)
        ' document is encryptred?
        If document.AuthorizationResult = Vintasoft.Imaging.Pdf.Security.AuthorizationResult.AuthenticationNotRequired Then
            System.Console.WriteLine("Document is not encrypted.")
            Return
        End If
    
        ' executes authentication
        If document.AuthorizationResult = Vintasoft.Imaging.Pdf.Security.AuthorizationResult.IncorrectPassword Then
            document.Authenticate(password)
        End If
    
        ' check authorization result
        If document.AuthorizationResult = Vintasoft.Imaging.Pdf.Security.AuthorizationResult.IncorrectPassword Then
            System.Console.WriteLine("The password is incorrect.")
        Else
            System.Console.Write("Authentication pass successfully, ")
            If document.AuthorizationResult = Vintasoft.Imaging.Pdf.Security.AuthorizationResult.OwnerPassword Then
                System.Console.WriteLine("owner password identified.")
            ElseIf document.AuthorizationResult = Vintasoft.Imaging.Pdf.Security.AuthorizationResult.UserPassword Then
                System.Console.WriteLine("user password identified.")
            ElseIf document.AuthorizationResult = (Vintasoft.Imaging.Pdf.Security.AuthorizationResult.UserPassword Or Vintasoft.Imaging.Pdf.Security.AuthorizationResult.OwnerPassword) Then
                System.Console.WriteLine("user and owner passwords are equal.")
            End If
        End If
    End Sub
    
    
    
    public static void DocumentAuthentication(Vintasoft.Imaging.Pdf.PdfDocument document, string password)
    {
        // document is encryptred?
        if (document.AuthorizationResult == 
            Vintasoft.Imaging.Pdf.Security.AuthorizationResult.AuthenticationNotRequired)
        {
            System.Console.WriteLine("Document is not encrypted.");
            return;
        }
    
        // executes authentication
        if (document.AuthorizationResult ==
            Vintasoft.Imaging.Pdf.Security.AuthorizationResult.IncorrectPassword)
        {
            document.Authenticate(password);
        }
    
        // check authorization result
        if (document.AuthorizationResult == 
            Vintasoft.Imaging.Pdf.Security.AuthorizationResult.IncorrectPassword)
        {
            System.Console.WriteLine("The password is incorrect.");
        }
        else
        {
            System.Console.Write("Authentication pass successfully, ");
            if (document.AuthorizationResult == Vintasoft.Imaging.Pdf.Security.AuthorizationResult.OwnerPassword)
                System.Console.WriteLine("owner password identified.");
            else if (document.AuthorizationResult == Vintasoft.Imaging.Pdf.Security.AuthorizationResult.UserPassword)
                System.Console.WriteLine("user password identified.");
            else if (document.AuthorizationResult == (Vintasoft.Imaging.Pdf.Security.AuthorizationResult.UserPassword | 
                Vintasoft.Imaging.Pdf.Security.AuthorizationResult.OwnerPassword))
                System.Console.WriteLine("user and owner passwords are equal.");
        }
    }
    
    

    Требования

    Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также