Thursday 23 August 2018

Grant a user access to view stored procedures in MSSQL

To grant access to a non admin user (assuming you have created them an SQL login imported from Active Directory), first run this command in a new query window from SSMS, substituting domain\username for the actual users credentials. Make sure you are targeting the correct database in the context menu


select 'GRANT VIEW DEFINITION ON [' + schema_name(schema_id) + '].[' + name +
       '] TO ' + '[domain\username]'
  from sys.all_objects
where type_desc = 'SQL_STORED_PROCEDURE'
   and schema_id <> schema_id('sys')


This will return a list of the commands you need to run to allow the user access to each stored procedure. Right click the table and select all then copy. Now paste this into your query window, overwriting the above command and run it. Voila, it is done.




Monday 23 July 2018

Problems using a disabled mailbox's email address as an alias on Exchange 2010















If you get an error like this after removing a mailbox or distribution group and adding its address as an alias to another account, it is happening because the auto-complete cache in Outlook and Outlook Web App uses the x500 email address instead of the SMTP (also know as LegacyExchangeDN), and this address was not found as the error is saying. 

To avoid this you need to add the LegacyExchangeDN as a email address to the desired mailbox too. You can find the DN in the error message: 
  1. Remove IMCEAEX- 
  1. Remove the @***************.com at the end 
  1. Replace all _ for / 
  1. Replace +20 for a blank space 
  1. You will have something like this: /O=***/OU=First Administrative Group/cn=Recipients/cn=*****
  1. Add this to the mailbox as a Custom Address by clicking the downwards arrow next to Add... and selecting Custom Address. Enter x500 as the E-mail type