Re: Verifying a user.
| От | Steven Klassen |
|---|---|
| Тема | Re: Verifying a user. |
| Дата | |
| Msg-id | 20041014170739.GA20464@commandprompt.com обсуждение исходный текст |
| Ответ на | Verifying a user. (Thomas Hallgren <thhal@mailblocks.com>) |
| Ответы |
Re: Verifying a user.
|
| Список | pgsql-general |
* Thomas Hallgren <thhal@mailblocks.com> [2004-10-14 17:27:20 +0200]: > I'm connected to a database and I want to verify that a username and > password for some user is correct. I know I can verify a users existence > by doing: > > select exists(select * from pg_user where usename = $1) You can get at the md5 hashed passwords in the pg_shadow table provided your user has the requisite permission. There may be something out there already that does this for you, but this is how the function/query might look if you went the Brute Force (tm) route. CREATE FUNCTION check_passwd(text,text) RETURNS boolean AS 'SELECT CASE WHEN passwd = md5($2) THEN true ELSE false END FROM pg_shadow WHERE usename = $1;' LANGUAGE sql; -- Steven Klassen - Lead Programmer Command Prompt, Inc. - http://www.commandprompt.com/ PostgreSQL Replication & Support Services, (503) 667-4564
В списке pgsql-general по дате отправления: