I am trying to validate a user against table aspnet_Membership that is created by asp.net MVC 5 entity framework . As most of you know it has hash password.
I think I found a link for C#
ASP.NET Identity default Password Hasher, how does it work and is it secure?
Any idea how to validate from Delphi? Thanks.
Finally I was able to get this done with help from my colleague and this link courtesy Malcolm Swaine at
http://www.codeproject.com/Articles/32600/Manually-validating-an-ASP-NET-user-account-with-a
Here is the final code that should do the trick.
uses DECHash,Data.Cloud.CloudAPI;
...
..
function GetHash_ASPNetMemberShip(const Password, Salt:string):string;
var
bPassword ,bSalt ,bSaltPassword: TBytes;
begin
bPassword:= TEncoding.Unicode.GetBytes(Password) ;
bSalt:= DecodeBytes64(Salt);
SetLength(bSaltPassword, length(bPassword)+length(bSalt));
Move(bSalt[0],bSaltPassword[0],length(bSalt));
Move(bPassword[0],bSaltPassword[length(bSalt)],length(bPassword));
Result := THash_SHA1.CalcBuffer(bSaltPassword[0], Length(bSaltPassword), TFormat_MIME64);
end;
I use Delphi XE8. Trying this example got error:
[dcc32 Fatal Error] Unit1.pas(7): F2613 Unit 'DECHash' not found.
Where I can find this unit? Google has't know nothing about it.
Related
I tried code found in Google but nothing works and in most cases it doesn't even compile (missing units, undeclared data types etc).
I finally found something that looks complete but shows "The handle is invalid" error:
http://rsdn.org/article/delphi/SMART.xml
You can download the file from here:
http://rsdn.org/article/delphi/smart/smart.zip
The problem is with function function OpenSMART(DrvNum:Byte): THandle;
hSMARTIOCTL:=CreateFile(PChar('\\.\PhysicalDrive'+inttostr(DrvNum)),GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ or FILE_SHARE_WRITE,nil,OPEN_EXISTING,0,0);
result:= hSMARTIOCTL;
How can I fix it or where can I find working example?
I use Delphi 7 Pro and Delphi 10.3.
OK, it needs to be run as admin. Then it just works.
I'm using Delphi 10.2 and the Native Excel 3 library to create spreadsheets.
I have the following code:
var
fWorkbook: IXLSWorkbook;
fSheet1: IXLSWorksheet;
begin
fWorkbook:=TXLSWorkbook.Create;
fSheet1:=fWorkBook.Sheets.Add;
fSheet1.Range['A1','A1'].ColumnWidth:=20;
fSheet1.Range['B1','B1'].ColumnWidth:=20;
fSheet1.Range['C1','C1'].ColumnWidth:=32;
fSheet1.Range['D1','D1'].ColumnWidth:=32;
fSheet1.Range['E1','E1'].ColumnWidth:=14;
fSheet1.Range['F1','F1'].ColumnWidth:=14;
fSheet1.Range['G1','G1'].ColumnWidth:=14;
fSheet1.Range['H1','H1'].ColumnWidth:=14;
fSheet1.Range['I1','I1'].ColumnWidth:=14;
fSheet1.Cells[1,1].Value:='Entry Type';
fSheet1.Cells[1,2].Value:='Intacct Acct #';
fSheet1.Cells[1,3].Value:='Intacct Acct # Description';
fSheet1.Cells[1,4].Value:='Store Name';
fSheet1.Cells[1,5].Value:='Department #';
fSheet1.Cells[1,6].Value:='Location ID';
fSheet1.Cells[1,7].Value:='Project ID';
fSheet1.Cells[1,8].Value:='Grant ID';
fSheet1.Cells[1,9].Value:='Net Amount';
intRow:=fWorkBook.SaveAs(Outfile);
'there is additional code after this.
end;
This code works every time on my development system. I've also used nExcel in other projects without a problem.
However, at the client's system, the fWorkbook.SaveAs generates an "Invalid Pointer" error or Access Violation. Since I cannot duplicate it, debugging is tough.
I have tried moving the SaveAs to various places (after the initial create, after the setting of column widths and where it is now).
Anyone seen this and/or have an explanation?
Thanks!
Malcolm
This problem was resolved by saving the workbook as an xlsx.
We use a Delphi 10 programme that reads in an Access database. I do not deeply understand how it does it, except that I believe it uses units called DAO.pas and DAO_TLB.pas.
I recently upgraded from Office 2007 to Office 2016, and since then the Delphi programme is unable to read from the database; it gives the error:
Project MyProj.exe raised exception class EOleSysError with message 'Class not registered'.
I have tried to search to find how to fix this but am struggling because I don't really understand what's going on under the hood. I tried to install the Access 2016 type library, but that didn't seem to make any difference.
Extremely grateful for any help.
Thanks,
Tom
EDIT: DAO.pas is here. DAO_TLB.pas is where the error is triggered; the function which errors is:
class function CoDBEngine.Create: _DBEngine;
begin
Result := CreateComObject(CLASS_DBEngine) as _DBEngine;
end;
Where CLASS_DBEngine is a constant declared as:
CLASS_DBEngine: TGUID = '{CD7791B9-43FD-42C5-AE42-8DD2811F0419}';
I have also just noticed that, when the error occurs, if I click continue rather than break, a new error appears, saying:
Class not registered, ClassID: {CD7791B9-43FD-42C5-AE42-8DD2811F0419}
i.e. the ClassID is the CLASS_DBEngine constant.
I want to load webpage html source into a Delphi (delphi 7) memo. It seems there are two methods for getting the source:
chromium1.Browser.MainFrame.GetSource(const visitor: icefstringvisitor);
chromium1.Browser.MainFrame.GetSourceproc(const proc: icefstringvisitorproc);
Can you please show how to use them. What is difference?
Thanks.
Update:
LD RD suggests in comments:
The GetSourceProc usage is exemplified in the examples following the source of TChromium, see GUIClient Main.pas
It works now, using GetSourceproc(const proc: icefstringvisitorproc);
Thank LD RD.
But i still do not know how to use MainFrame.GetSource(const visitor: icefstringvisitor);
I am using Delphi Prism to connect to an Advantage Database Server. I created a connection using the server explorer to the database. I added a dataset object to my project and added a table to the dataset. Everything works fine in the IDE, however, I get an error in the generated designer code on the table adapter constructor.
The error is: (PE26) Class type expected.
Here is the generated code:
{ Presidents.PresidentsTableAdapters.USPRESIDENTSTableAdapter }
constructor Presidents.PresidentsTableAdapters.USPRESIDENTSTableAdapter;
begin
self.ClearBeforeFill := true;
end;
does it help to leave out the "self."? i would expect "self." is unnecessary. i use it only rarely.
Can you show the full file? The error says that "Presidents.PresidentsTableAdapters.USPRESIDENTSTableAdapter" is not a known class type.