是否可以将可信连接 (SSPI) 与 SQLDMO API 结合使用?
我通过 .NET 使用 DMO API 为 SQL Server 2000 Agent 上的作业调度功能提供替代接口。工作代码看起来像这样:
using SQLDMO;
internal class TestDmo {
public void StartJob() {
SQLServerClass sqlServer = new SQLServerClass();
sqlServer.Connect("MyServerName", "sql_user_id", "p@ssword"); // no trusted/SSPI overload?
foreach (Job job in sqlServer.JobServer.Jobs) {
if (!job.Name.Equals("MyJob")) continue;
job.Start(null);
}
}
}
一切都以上面列出的形式工作(提供了 uid/pwd 的 SQL Server 身份验证),但我还想提供一个选项来以受信任的用户身份进行身份验证(又名 SSPI,受信任的连接)
是这样的可以在 DMO API 中吗?如果是这样怎么办?
注意:SQLServerClass.Connect 方法似乎没有任何重载,我已经尝试为用户 ID 和密码传递空值,但无济于事,Google 还没有提供帮助。有什么想法吗?
I am using the DMO API via .NET to provide an alternative interface to job scheduling functionality on SQL Server 2000 Agent. The working code looks something like this:
using SQLDMO;
internal class TestDmo {
public void StartJob() {
SQLServerClass sqlServer = new SQLServerClass();
sqlServer.Connect("MyServerName", "sql_user_id", "p@ssword"); // no trusted/SSPI overload?
foreach (Job job in sqlServer.JobServer.Jobs) {
if (!job.Name.Equals("MyJob")) continue;
job.Start(null);
}
}
}
Everything works in the above-listed form (SQL Server authentication with uid/pwd provided) but I would also like to provide an option to authenticate as a trusted user (aka SSPI, Trusted Connection)
Is this possible in the DMO API? If so how?
Note: The SQLServerClass.Connect method does not seem to have any overloads, I already tried to pass null values for the user id and password to no avail and the Googles has not been helpful yet. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
来自文档:
因此,在调用 Connect 之前,您必须将
LoginSecure
属性设置为true
。然后,为最后两个参数传递哪个值并不重要。From the documentation:
Thus, you have to set the
LoginSecure
property totrue
before calling Connect. Then, it does not matter which values you pass for the last two parameters.当然,您可以使用 LoginSecure 属性:(
实际上,我不记得是否必须传递 null 或空字符串......)
Sure, you can use the LoginSecure property:
(actually, I don't remember if you must pas null or empty strings...)
设置 SQLServerClass.LoginSecure = true 并将用户名和密码保留为空。
请查看此处了解更多信息。不过,我刚刚注意到
LoginSecure
已被弃用。显然,SQL-DMO 已被 SMO 取代。Set
SQLServerClass.LoginSecure = true
and leave user name and password null.Have a look here for more information. I just noticed that
LoginSecure
is deprecated, though. Apparently, SQL-DMO has been superseded by SMO.