重新部署时,t-sql c#clr执行权限会丢失。

发布于 2025-01-28 00:55:02 字数 203 浏览 3 评论 0原文

我已经继承了一个VS2015 .NET C#项目,该项目将C#组件作为CLR存储过程部署到SQL Server 2016。它已经无缝地工作了很多年。

但是最近我注意到,当我重新部署(又称“发布数据库”)时,其中一个汇编似乎丢失了一个用户的执行权限。

有什么方法可以让项目重新申请重新启动后?该脚本必须知道我要部署更新的CLR的SQL Server实例和数据库。谢谢

I have inherited a VS2015 .NET C# project that deploys C# assemblies as CLR stored procedures to SQL Server 2016. It has worked seamlessly for many years.

However recently I've noticed that when I redeploy (a.k.a "Publish Database"), one of the assemblies seems to lose EXECUTE permissions for one of the users.

Is there a way I can have the project reapply the EXECUTE permissions after it has redeployed? The script would have to know which SQL Server instance and database I'm deploying the updated CLR to. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

豆芽 2025-02-04 00:55:02

从未给予用户对程序集执行权限。我怀疑您意味着执行权限到本程序中引用代码的SQLCLR存储过程中的一个(或更多)。您可以在Visual Studio Project中相当轻松地将其释放后T-SQL脚本添加到Publish Scripts(通过VS的SSDT)中。在此T-SQL脚本中,您只需添加Grant语句即可。而且,如果仅在一个特定数据库/实例中有意义,则可以将该授予语句包装在中,如果 block检查当前实例和/或数据库名称。

在VS 2015中添加后发行脚本的步骤:

  1. 在解决方案资源管理器中选择项目
  2. to to“ project”菜单
  3. 选择“添加新项目...”
  4. 选择“ SQL Server” - > “用户脚本”
  5. 选择“ Post Deployment脚本”
  6. 在“名称:”字段中键入脚本的名称
  7. 单击“添加”按钮
  8. 编辑新的SQL脚本以添加Grant> Grant语句(S )

该脚本的内容将添加到VS / SSDT生成的任何 exployment < / em> / 发布< / em> / prublish < / em>脚本,因此,您将在执行这些DB中执行这些脚本脚本。

User are never given execute permissions to an assembly. I suspect you are meaning execute permissions to one (or more)of the SQLCLR stored procedures that reference code within this assembly. You can fairly easily add a post-release T-SQL script to your Visual Studio project that will get included in the publish scripts (by SSDT via VS). In this T-SQL script you just add the GRANT statement. And, if it only makes sense in one particular database / instance, then you can wrap that GRANT statement in an IF block that checks for the current instance and/or database names.

Steps for adding a post-release script in VS 2015:

  1. Select project in Solution Explorer
  2. Go to "Project" menu
  3. Select "Add New Item..."
  4. Select "SQL Server" -> "User Scripts"
  5. Select "Post-Deployment Script"
  6. Type a name for the script down in the "Name:" field
  7. Click the "Add" button
  8. Edit the new SQL script to add the GRANT statement(s)

The contents of that script will be added to the end of any deployment / publish script generated by VS / SSDT, and hence will execute in every DB in which you execute those scripts.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文