UserName property

Gets the user name of the account.

Syntax

string UserName {get;}

Return value

Returns the user name of the account.

Discussion

If the account is a Windows account, the user name is the Windows domain account name. If the account is an SQL Server login account, the user name is the SQL Server account name.

Example

The following code sample illustrates using this property as an input parameter to the AddCollectorAccount method:

...

' Copy Collector accounts from current active audit store database
    SET objCollectorAccounts = objActiveDatabase.CollectorAccounts
    FOR EACH objCollectorAccount IN objCollectorAccounts
        objAuditStoreDatabase.AddCollectorAccount objCollectorAccount.UserName
        wscript.echo "Added Collector account '" & objCollectorAccount.UserName & "'."