[英]Is it possible to use a trusted connection (SSPI) with the SQLDMO API?
I am using the DMO API via .NET to provide an alternative interface to job scheduling functionality on SQL Server 2000 Agent. 我通过.NET使用DMO API为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) 一切都以上面列出的形式工作(提供了uid / pwd的SQL Server身份验证)但我还想提供一个选项来作为可信用户进行身份验证(也称为SSPI,可信连接)
Is this possible in the DMO API? 这可能在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. 注意:SQLServerClass.Connect方法似乎没有任何重载,我已经尝试传递用户ID和密码的空值无效,谷歌还没有帮助。 Any ideas?
有任何想法吗?
From the documentation : 从文档 :
object.Connect( [ ServerName ] , [ Login ] , [ Password ] )
object.Connect([ServerName],[Login],[Password])
[...]
[...]
Use the Login and Password arguments to specify values used for SQL Server Authentication.
使用Login和Password参数指定用于SQL Server身份验证的值。 To use Windows Authentication for the connection, set the LoginSecure property to TRUE prior to calling the Connect method.
要对连接使用Windows身份验证,请在调用Connect方法之前将LoginSecure属性设置为TRUE。 When LoginSecure is TRUE, any values provided in the Login and Password arguments are ignored.
当LoginSecure为TRUE时,将忽略Login和Password参数中提供的任何值。
Thus, you have to set the LoginSecure
property to true
before calling Connect. 因此,您必须在调用Connect之前将
LoginSecure
属性设置为true
。 Then, it does not matter which values you pass for the last two parameters. 然后,为最后两个参数传递的值无关紧要。
Sure, you can use the LoginSecure property: 当然,您可以使用LoginSecure属性:
SQLServerClass sqlServer = new SQLServerClass();
sqlServer.LoginSecure = true;
sqlServer.Connect("MyServerName", null, null);
(actually, I don't remember if you must pas null or empty strings...) (实际上,我不记得你是否必须空或空字符串...)
Set SQLServerClass.LoginSecure = true
and leave user name and password null. 设置
SQLServerClass.LoginSecure = true
并保留用户名和密码为null。
Have a look here for more information. 在这里查看更多信息。 I just noticed that
LoginSecure
is deprecated, though. 我只是注意到不推荐使用
LoginSecure
。 Apparently, SQL-DMO has been superseded by SMO. 显然,SQL-DMO已被SMO取代。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.