RequireAuthentication Method  

Send a response to the client indicating that authentication is required.


object.RequireAuthentication( ClientId, [AuthType], [Realm] )


An integer that identifies the client session.
An optional integer value that corresponds to a result code, informing the client if the redirection is permanent or temporary. If this parameter is omitted, then Basic authentication will be used by default. This parameter may be one of the following values:
Value Constant Description
1 httpAuthBasic This option specifies the Basic authentication scheme should be used. This option is supported by all clients that support at least version 1.0 of the protocol.
An optional string value that is displayed a web browser to indicate to the user which username and password they should use. If this parameter is omitted or is an empty string, the domain name the client used to establish the connection will be used.

Return Value

A value of zero is returned if the method completed successfully. Otherwise, a non-zero error code is returned which indicates the cause of the failure.


The RequireAuthentication method can be used within an OnCommand event handler to indicate to the client that it must provide a username and password to access the requested resource. The client should respond by issuing another request that includes the required credentials. To determine if a client has included valid credentials with its request, check the value of the IsAuthenticated property.

Some clients may require that the session be secure if authentication is requested or display warning messages to the user if the connection is not secure. If your application will require clients to authenticate before accessing specific resources, it is recommended that you enable security by setting the Secure property to True prior to starting the server.

See Also

SendError Method, SendResponse Method, OnAuthenticate Event, OnCommand Event