Search Postgresql Archives

Re: change user password

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> hi, is it possible to change the current user's password from a
> function/stored procedure , I mean,  is there a system function/stored
> procedure to do it? like the dbo.sp_password found in adaptive server
> anywhere.
>


CREATE OR REPLACE FUNCTION public.alter_password(name, name)
  RETURNS "varchar" AS
'
DECLARE
  l_user ALIAS FOR $1;
  l_pwd ALIAS FOR $2;
  CMD VARCHAR;
BEGIN
  CMD := \'ALTER USER "\' || l_user || \'" WITH ENCRYPTED PASSWORD \' ||
\'\'\'\' || l_pwd || \'\'\'\' || \' VALID UNTIL \' || \'\'\'\' ||
CURRENT_DATE+INTERVAL \'30 days\' || \'\'\'\';
  EXECUTE CMD;
  RETURN \'ALTER USER\';
END;
'
  LANGUAGE 'plpgsql' VOLATILE SECURITY DEFINER;


-- Of course, you'ld want to be careful about whom was granted execute 
permission on this.

-- BMT


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@xxxxxxxxxxxxxx)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux