Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. EXECUTE msdb.dbo.sysmail_update_account_sp
  2.  
  3. USE [master];
  4. go
  5.  
  6. -- DROP CERTIFICATE [MailSetupCert];
  7.  
  8. IF NOT EXISTS (SELECT * FROM sys.certificates WHERE name = 'MailSetupCert')
  9. BEGIN
  10. PRINT 'trying to create certificate MailSetupCert'
  11. CREATE CERTIFICATE [MailSetupCert]
  12. ENCRYPTION BY PASSWORD = N'OurSp3cialPassW0rd!!'
  13. WITH SUBJECT = N'Certificate for Managing Special Permissions';
  14. END
  15.  
  16. CREATE LOGIN [dbMailAdmin] FROM CERTIFICATE [MailSetupCert];
  17. GRANT CONTROL SERVER TO [dbMailAdmin];#
  18. -- also tried EXEC sp_addsrvrolemember @loginame = N'dbMailAdmin', @rolename = N'sysadmin'
  19.  
  20. BACKUP CERTIFICATE [MailSetupCert]
  21. TO FILE = 'C:TEMPEmailSetup.CER'
  22. WITH PRIVATE KEY
  23. (
  24. FILE = 'C:TEMPEmailSetup.PVK',
  25. DECRYPTION BY PASSWORD = 'OurSp3cialPassW0rd!!',
  26. ENCRYPTION BY PASSWORD = 'AnotherSp3cialPassW0rd!!'
  27. );
  28. -
  29. USE [UserDatabase];
  30. go
  31.  
  32. IF NOT EXISTS (SELECT * FROM sys.certificates WHERE name = 'MailSetupCert')
  33. BEGIN
  34. PRINT 'trying to create certificate MailSetupCert from file'
  35. CREATE CERTIFICATE [MailSetupCert]
  36. FROM FILE = 'C:tempEmailSetup.CER'
  37. WITH PRIVATE KEY (
  38. FILE = 'C:tempEmailSetup.PVK',
  39. DECRYPTION BY PASSWORD = 'AnotherSp3cialPassW0rd!!',
  40. ENCRYPTION BY PASSWORD = 'OurSp3cialPassW0rd!!'
  41. );
  42. END
  43.  
  44. ADD SIGNATURE TO dbo.ai_UpdateWebSetupEmail
  45. BY CERTIFICATE [MailSetupCert] WITH PASSWORD = 'OurSp3cialPassW0rd!';
  46.  
  47. GRANT EXEC ON ai_UpdateWebSetupEmail TO DatabaseUser
  48.  
  49. declare @p10 int
  50. set @p10=0
  51. exec sp_executesql N'EXEC @RETURN_VALUE = [dbo].[ai_UpdateWebSetupEmail] @ParamWebAppSmtpServer = @p0, @ParamWebAppSMTPPort = @p1, @ParamWebAppSMTPUser = @p2, @ParamWebAppSMTPPwd = @p3, @ParamWebAppEmailMessageDisclaimer = @p4, @ParamSMTPFrom = @p5, @ParamSMTPSSL = @p6',N'@p0 varchar(8000),@p1 int,@p2 varchar(8000),@p3 varchar(8000),@p4 varchar(8000),@p5 varchar(8000),@p6 int,@RETURN_VALUE int output',@p0='smtp.gmail.com',@p1=587,@p2='testmail@nosuchdomain.com',@p3='emailpassword',@p4='The Email Disclaimer: IMPORTANT: This email is intended for the use of the individual addressee(s) named above and may contain information that is confidential, privileged or unsuitable for overly sensitive persons with low self-esteem, no sense of humour or irrational religious beliefs. If you are not the intended recipient, any dissemination, distribution or copying of this email is not authorised (either explicitly or implicitly) and constitutes an irritating social faux pas. Unless the word absquatulation has been used in its correct context somewhere other than in this warning, it does not have any legal or grammatical use and may be ignored. No animals were harmed in the transmission of this email, although the kelpie next door is living on borrowed time, let me tell you. Those of you with an overwhelming fear of the unknown will be gratified to learn that there is no hidden message revealed by reading this warning backwards, so just ignore that Alert Notice from Microsoft.',@p5='testmail@nosuchdomain.com',@p6=2,@RETURN_VALUE=@p10 output
  52. select @p10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement