开发者

How can I get an Interbase password if I have only the BDE alias?

I am trying to connect to a Interbase DB at runtime via the BDE. I am trying to do this in a formless project (but not a console app). The alias is known. I retrieve the alias from the registry. Example: MyAlias.

//create alias params list  
AParams:= TStringList.Create;  

//create a session to get alias parameters  
ASession:= TSession.Create(nil);  
ASession.SessionName := 'MainSession';  
try  
 ASession.GetAliasParams(tmpAlias, AParams);  
finally  
 ASession.Free;  
end;  


//connect to database 
dbMain:= TDatabase.Create(nil);  
with dbMain do  
begin  
 //AliasName:= 'MyAlias';  
 DatabaseName:= 'test';  
 LoginPrompt:= False;  
 Params.Assign(AParams);  
 try  
  Connected:=True;  
  if Connected then ShowMessage('Connected!') else ShowMessage('Failed to Connect!');    
 finally  
  Free;  
 end; //try  
end;//with  

//free alias params list  
AParams.Free;

Anyway, it doesn't look like the Session.GetParams actually gets the password. How do I get the password? Is there a way to get all the connection info from the BDE and make the connectio开发者_Go百科n if I know the alias? I'd rather not hard-code the username and password in case the client changes them in the future.


Shane, if you could get the password from the database only knowing the alias, all the security of the database will be pointless. so the answer is NO , you cannot retrieve this info only knowing the BDE alias. the way to connect to a database with a password protection is request the user and password to the final user or storing this info in an encrypted configuration file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜