SubscriptionConditionScheduledRule.SqlUserName Property

Gets or sets the name of the database user Notification Services creates to run the statements specified in the SqlExpression property.

命名空间: Microsoft.SqlServer.Management.Nmo
程序集: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)

语法

声明
Public Property SqlUserName As String
public string SqlUserName { get; set; }
public:
property String^ SqlUserName {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_SqlUserName ()

/** @property */
public void set_SqlUserName (String value)
public function get SqlUserName () : String

public function set SqlUserName (value : String)

属性值

A String that specifies the database user name Notification Services creates. Database user names typically, but are not required to, match their associated login name.

备注

All SubscriptionConditionScheduledRule rules execute in the context of a database user that you specify. Using a low-privileged user minimizes the security threat in case anyone compromises your subscription management interface and inserts conditions that attempt to access other tables or perform other actions.

Notification Services creates the user account; it cannot exist before you create the application.

Make sure the database user, and its associated Microsoft SQL Server Login, which is named using the SqlLoginName property, has restricted permissions in the database. Also make sure the user and the associated SqlLogin are not likely to be removed from the server or the domain while the application is deployed, as this will cause application errors.

Notification Services grants the necessary permissions on Notification Services objects, but does not grant permissions on the input tables or views, nor does it grant permissions on any user-defined functions that are used by condition actions. You need to grant these permissions when deploying the application. For more information about granting these permissions, see 定义条件操作.

示例

The following examples show how to define a condition-based, scheduled subscription rule and add it to a subscription class:

// Add a rule to generate condition-based, scheduled notifications
SubscriptionConditionScheduledRule flightConditionScheduledRule = 
    new SubscriptionConditionScheduledRule(
    flightSubscriptions, "FlightConditionScheduledRule");
flightConditionScheduledRule.ActionTimeout = 
    new TimeSpan(0, 2, 0);
flightConditionScheduledRule.SqlLoginName = "MyLowPrivLogin";
flightConditionScheduledRule.SqlUserName = "MyLowPrivUser";
flightConditionScheduledRule.InputTypeName = "FlightEventChronicle";
flightConditionScheduledRule.InputTypeSchema = "MyAppSchema";
flightConditionScheduledRule.SqlExpression =
    "INSERT INTO MyAppSchema.FlightNotifications (SubscriberId, " +
    "DeviceName, SubscriberLocale, LeavingFrom, GoingTo, Price) " +
    "SELECT [Subscription.SubscriberId], " +
    "[Subscription.DeviceName], [Subscription.SubscriberLocale], " +
    "[Input.LeavingFrom], [Input.GoingTo], [Input.Price] " +
    "FROM MyAppSchema.FlightConditionScheduledRule;";
flightSubscriptions.SubscriptionConditionScheduledRules.Add(
    flightConditionScheduledRule);
' Add a rule to generate condition-based, scheduled notifications
Dim flightConditionScheduledRule As _
    SubscriptionConditionScheduledRule = _
    New SubscriptionConditionScheduledRule( _
    flightSubscriptions, "FlightConditionScheduledRule")
flightConditionScheduledRule.ActionTimeout = _
    New TimeSpan(0, 2, 0)
flightConditionScheduledRule.SqlLoginName = "MyLowPrivLogin"
flightConditionScheduledRule.SqlUserName = "MyLowPrivUser"
flightConditionScheduledRule.InputTypeName = _
    "FlightEventChronicle"
flightConditionScheduledRule.InputTypeSchema = "MyAppSchema"
flightConditionScheduledRule.SqlExpression = _
    "INSERT INTO MyAppSchema.FlightNotifications " + _
 "(SubscriberId, DeviceName, SubscriberLocale, LeavingFrom, " + _
 "GoingTo, Price) SELECT [Subscription.SubscriberId], " + _
 "[Subscription.DeviceName], [Subscription.SubscriberLocale], " + _
 "[Input.LeavingFrom], [Input.GoingTo], [Input.Price] " + _
 "FROM MyAppSchema.FlightConditionScheduledRule;"
flightSubscriptions.SubscriptionConditionScheduledRules.Add( _
    flightConditionScheduledRule)

线程安全

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

平台

开发平台

有关支持的平台列表,请参阅安装 SQL Server 2005 的硬件和软件要求。

目标平台

有关支持的平台列表,请参阅安装 SQL Server 2005 的硬件和软件要求。

请参阅

参考

SubscriptionConditionScheduledRule Class
SubscriptionConditionScheduledRule Members
Microsoft.SqlServer.Management.Nmo Namespace

其他资源

定义预定规则
定义条件操作
ScheduledRule Element (ADF)
ConditionAction Element (ADF)