This documentation is archived and is not being maintained.

Authorization.Message Property

Gets the message returned to the server in response to an authentication challenge.

[Visual Basic]
Public ReadOnly Property Message As String
[C#]
public string Message {get;}
[C++]
public: __property String* get_Message();
[JScript]
public function get Message() : String;

Property Value

The message that will be returned to the server in response to an authentication challenge.

Remarks

The Message property contains the authorization string that the client will return to the server when accessing protected resources. The actual contents of the message is defined by the authentication type the client and server are using. Basic HTTP authentication, for example, uses a different message than Kerberos authentication.

When an authentication module supports preauthentication, the Message property is sent with the initial request.

Example

[Visual Basic, C#, C++] The following example uses the Message property to get the message returned to the server in response to an authentication challenge. For a complete example, refer to the AuthenticationManager class.

[Visual Basic] 

        ' Create the encrypted string according to the Basic authentication format as
        ' follows:
        ' a)Concatenate the username and password separated by colon;
        ' b)Apply ASCII encoding to obtain a stream of bytes;
        ' c)Apply Base64 encoding to this array of bytes to obtain the encoded 
        ' authorization.
        Dim BasicEncrypt As String = MyCreds.UserName + ":" + MyCreds.Password

        Dim BasicToken As String = "Basic " + Convert.ToBase64String(ASCII.GetBytes(BasicEncrypt))

        ' Create an Authorization object using the encoded authorization above.
        Dim resourceAuthorization As New Authorization(BasicToken)

        ' Get the Message property, which contains the authorization string that the 
        ' client returns to the server when accessing protected resources.
        Console.WriteLine(ControlChars.Lf + " Authorization Message:{0}", resourceAuthorization.Message)

        ' Get the Complete property, which is set to true when the authentication process 
        ' between the client and the server is finished.
        Console.WriteLine(ControlChars.Lf + " Authorization Complete:{0}", resourceAuthorization.Complete)

        Console.WriteLine(ControlChars.Lf + " Authorization ConnectionGroupId:{0}", resourceAuthorization.ConnectionGroupId)


[C#] 
[C++] 
// Create the encrypted string according to the Basic authentication format as
// follows:
// a)Concatenate username and password separated by colon;
// b)Apply ASCII encoding to obtain a stream of bytes;
// c)Apply Base64 Encoding to this array of bytes to obtain the encoded
// authorization.
String* BasicEncrypt = String::Concat(MyCreds->UserName, S":", MyCreds->Password);

String* BasicToken = 
   String::Concat(S"Basic ", Convert::ToBase64String(ASCII->GetBytes(BasicEncrypt)));

// Create an Authorization object using the above encoded authorization.
Authorization* resourceAuthorization = new Authorization(BasicToken);

// Get the Message property which contains the authorization string that the
// client returns to the server when accessing protected resources
Console::WriteLine(S"\n Authorization Message: {0}", resourceAuthorization->Message);

// Get the Complete property which is set to true when the authentication process
// between the client and the server is finished.
Console::WriteLine(S"\n Authorization Complete: {0}", 
   __box(resourceAuthorization->Complete));

Console::WriteLine(S"\n Authorization ConnectionGroupId: {0}", 
   resourceAuthorization->ConnectionGroupId);
return resourceAuthorization;
   }
};

// This is the program entry point. It allows the user to enter
// her credentials and the Internet resource (Web page) to access.
// It also unregisters the standard and registers the customized basic
// authentication.
int main() {
   String* args[] = Environment::GetCommandLineArgs();

   if (args->Length < 4)
TestAuthentication::showusage();
   else {
// Read the user's credentials.
TestAuthentication::uri = args[1];
TestAuthentication::username = args[2];
TestAuthentication::password = args[3];

if (args->Length == 4)
   TestAuthentication::domain = String::Empty;
else
   // If the domain exists, store it. Usually the domain name
   // is by default the name of the server hosting the Internet
   // resource.
   TestAuthentication::domain = args[4];


// Instantiate the custom Basic authentication module.
CustomBasic* customBasicModule = new CustomBasic();

// Unregister the standard Basic authentication module.
AuthenticationManager::Unregister(S"Basic");

// Register the custom Basic authentication module.
AuthenticationManager::Register(customBasicModule);

// Display registered Authorization modules.
TestAuthentication::displayRegisteredModules();

// Read the specified page and display it on the console.
TestAuthentication::getPage(TestAuthentication::uri);
   }
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Authorization Class | Authorization Members | System.Net Namespace | IAuthenticationModule

Show: