#1 mORMot 1 » Load file failed (fill by zero) » 2014-02-26 06:29:52

VLT
Replies: 1

in SynCrtSock (in procedure THttpServer.Process(ClientSock: THttpServerSocket; aCallingThread: TNotifiedThread);)

      try
        FileToSend := TFileStream.Create(
          {$ifdef UNICODE}UTF8ToUnicodeString{$else}Utf8ToAnsi{$endif}(Context.OutContent),
          fmOpenRead or fmShareDenyNone);
        try
          SetString(Context.fOutContent,nil,FileToSend.Size);
          FileToSend.Position := 0;
          FileToSend.Read(Pointer(Context.fOutContent),length(Context.fOutContent)); // THIS PROBLEM !!! 
          Context.OutContentType := '';
       finally
          FileToSend.Free;
        end;
      except
        on Exception do begin
         Code := 404;
         Context.OutContent := '';
        end;
      end;
      try
        FileToSend := TFileStream.Create(
          {$ifdef UNICODE}UTF8ToUnicodeString{$else}Utf8ToAnsi{$endif}(Context.OutContent),
          fmOpenRead or fmShareDenyNone);
        try
          SetString(Context.fOutContent,nil,FileToSend.Size);
          FileToSend.Position := 0;
          FileToSend.Read(PAnsiChar(Context.fOutContent)^,length(Context.fOutContent)); // WORKED !!! 
          Context.OutContentType := '';
       finally
          FileToSend.Free;
        end;
      except
        on Exception do begin
         Code := 404;
         Context.OutContent := '';
        end;
      end;

#2 mORMot 1 » AD authentication (Tutorial) » 2014-02-19 07:48:00

VLT
Replies: 1

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

Board footer

Powered by FluxBB