TsgcWebSocketHTTPServer › 事件 › OnNegotiateAuthentication

OnNegotiateAuthentication 事件

当 Kerberos 或 NTLM(Negotiate)交换完成时触发,以便应用程序接受或拒绝已通过身份验证的主体。

语法

property OnNegotiateAuthentication: TsgcWSNegotiateAuthenticationEvent;
// TsgcWSNegotiateAuthenticationEvent = procedure(Connection: TsgcWSConnection; const aPrincipal: String; var Authenticated: Boolean) of object

默认值

—

备注

需要 sgcWebSockets Enterprise Edition。当由 Authentication.Negotiate.Enabled 启动的 Kerberos 或 NTLM 交换完成时,将触发 OnNegotiateAuthentication。aPrincipal 是已通过身份验证的身份:Windows 上为 DOMAIN\user,Linux 上为 user@REALM。Authenticated 传入时为 True,因此在没有处理程序的情况下,Windows 或 Kerberos 已验证的每个主体都会被接受。将其设为 False 可拒绝该主体,此时客户端会收到 401 响应。在 Indy 服务器上,之后可通过 TsgcWSConnectionServer(Connection).Authentication.User 读取主体(AuthType 为 authNegotiate)。请参阅 Kerberos 和 Negotiate 身份验证。

示例


procedure TForm1.OnNegotiateAuthenticationEvent(Connection: TsgcWSConnection;
  const aPrincipal: String; var Authenticated: Boolean);
begin
  Authenticated := SameText(aPrincipal, 'EXAMPLE\alice') or
    SameText(aPrincipal, 'EXAMPLE\bob');
end;

返回事件