Server.Logins Server.Logins Server.Logins Property

Definition

Represents a collection of Login objects. Each Login object represents a login defined on the instance of SQL Server.

public:
 property Microsoft::SqlServer::Management::Smo::LoginCollection ^ Logins { Microsoft::SqlServer::Management::Smo::LoginCollection ^ get(); };
[Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcObject(Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcContainerRelationship.ObjectContainer, Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcContainerCardinality.ZeroToAny, typeof(Microsoft.SqlServer.Management.Smo.Login))]
public Microsoft.SqlServer.Management.Smo.LoginCollection Logins { get; }
Public ReadOnly Property Logins As LoginCollection
Property Value

A LoginCollection object that represents all the logins defined on the instance of SQL Server.

Examples

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  
}  

Remarks

The Logins property points to the LoginCollection object. The collection can be used to enumerate all the logins for the instance of SQL Server. If you are using Windows Authentication only, the Logins property represents Windows-authenticated accounts. With Mixed Mode Authentication, this property also represents accounts that are created by using SQL Server Authentication.

Applies to