次の方法で共有


Logins プロパティ

Login オブジェクトのコレクションを表します。各 Login オブジェクトは、SQL Server のインスタンスで定義されたログインを表します。

名前空間:  Microsoft.SqlServer.Management.Smo
アセンブリ:  Microsoft.SqlServer.Smo (Microsoft.SqlServer.Smo.dll)

構文

'宣言
<SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny,  _
    GetType(Login))> _
Public ReadOnly Property Logins As LoginCollection
    Get
'使用
Dim instance As Server
Dim value As LoginCollection

value = instance.Logins
[SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny, 
    typeof(Login))]
public LoginCollection Logins { get; }
[SfcObjectAttribute(SfcContainerRelationship::ObjectContainer, SfcContainerCardinality::ZeroToAny, 
    typeof(Login))]
public:
property LoginCollection^ Logins {
    LoginCollection^ get ();
}
[<SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny, 
    typeof(Login))>]
member Logins : LoginCollection
function get Logins () : LoginCollection

プロパティ値

型: Microsoft.SqlServer.Management.Smo. . :: . .LoginCollection
SQL Server のインスタンスで定義されたすべてのログインを表す LoginCollection オブジェクトです。

説明

Logins プロパティは LoginCollection オブジェクトを参照しています。このコレクションを使用して、SQL Server のインスタンスに関するすべてのログインを列挙できます。Windows 認証のみを使用している場合、Logins プロパティは Windows で認証されるアカウントを表します。混合モード認証を使用している場合、このプロパティは、SQL Server 認証を使用して作成されたアカウントも表します。

使用例

Visual Basic

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server
'Display the logins on the instance of SQL Server.
Dim lg As Login
For Each lg In srv.Logins
   Console.WriteLine(lg.Name)
Next

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
foreach ($lg in $srv.Logins)
{
   Write-Host $lg.Name
}