This procedure can be used to provide the security options in windows NTFS folders with default permissions.
This procedure accepts 5 parameters
-- @path - The path of the share folder
-- @traverse - To specify if the permission needs to be traversed to sub folders or not
-- Y - to give permissions to subfolders also
-- N - to not give permissions to sub folders
-- @type - This accepts 4 vaules
-- g - to grant access to the specified folder and/or sub-folders
-- p - to modify access to the specified folder and/or sub-folders
-- r - to revoke access to the specified folder and/or sub-folders
-- d - to deny access to the specified folder and/or sub-folders
-- @user - the user to whom access needs to be specified
-- @perm - type of permission to be given and this accepts 4 parameters
-- N - No Permissions
-- R - Read
-- C - Change
-- F - Full Control
Script:
create procedure windowssec (@path varchar(200), @traverse char,@type char,@user varchar(50),@perm char)
as
begin
declare @cmd varchar(100)
if (upper(@traverse) <> 'Y')
begin
set @cmd = 'cacls '+@path
end
else
begin
set @cmd = 'cacls '+@path+' /t '
end
if (lower(@type) = 'r' or lower(@type) = 'd')
begin
set @cmd = @cmd+' /e /'+@type+' '+@user
exec master..xp_cmdshell @cmd
end
else
begin
set @cmd = @cmd+' /e /'+@type+' '+@user+':'+@perm
exec master..xp_cmdshell @cmd
END
end
Wow! Wow! Wow! THANK YOU!
-
I announced my retirement from SQL/tech here and your comments on my blog,
on LinkedIn, and on Facebook were overwhelming and humbling! I’m so touched
by t...
1 year ago
No comments:
Post a Comment