#1 2014-02-19 07:48:00

VLT
Member
Registered: 2014-02-19
Posts: 2

AD authentication (Tutorial)

I had a problem: i needed to authenticate the user using domain authentication.
... and i decided to rewrite the GetUser method:

Моя проблема заключалась в следующем, мне необходимо было авторизовывать пользователя с помощью доменной аутентификации. Ничего лучшего не придумал как переписать метод GetUser:

function TSQLRestServerAuthenticationSSPIMod.GetUser(Ctxt: TSQLRestServerURIContext; const aUserName: RawUTF8): TSQLAuthUser;
begin
  Result := Ctxt.Server.SQLAuthUserClass.Create(Ctxt.Server,'LogonName=?',[aUserName]);
  if Result.ID = 0 then
  begin
    Result := Ctxt.Server.SQLAuthUserClass.Create;
    try
      Result.LogonName := aUserName;
      Result.DisplayName := aUserName;
      Result.GroupRights := TSQLAuthGroup(Ctxt.Server.MainFieldID(TSQLAuthGroup,'User'));

    // fix "User.LogonName not found in AuthUser table"

    Ctxt.Server.Add(Result, true);
  finally
  end;
end;

and fix in mORMot.pas (TSQLRestServerAuthenticationSSPI.Auth)

      
    User := GetUser(Ctxt,User.LogonName); // AV !!! class is not created !!!
    if User<>nil then
    try
      User.PasswordHashHexa := ''; // override with context

to

      
    User := GetUser(Ctxt, UserName); 
    if User<>nil then
    try
      User.PasswordHashHexa := ''; // override with context

Last edited by VLT (2014-02-19 08:46:06)

Offline

#2 2014-02-19 16:07:09

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,606
Website

Re: AD authentication (Tutorial)

We just fixed this unexpected GPF issue when using Windows Authentication.
See http://synopse.info/fossil/info/577dd56be2
Thanks for the feedback!

Offline

Board footer

Powered by FluxBB