TargetUserName - property in ROOT\Microsoft\SqlServer\ServerEvents\MSSQLSERVER namespace

TargetUserName in other namespaces

List of classes with TargetUserName local property in ROOT\Microsoft\SqlServer\ServerEvents\MSSQLSERVER namespace

propertyClassOrigin
TargetUserNameAUDIT_ADD_DB_USER_EVENTAUDIT_ADD_DB_USER_EVENT
TargetUserNameAUDIT_ADD_MEMBER_TO_DB_ROLE_EVENTAUDIT_ADD_MEMBER_TO_DB_ROLE_EVENT
TargetUserNameAUDIT_CHANGE_DATABASE_OWNERAUDIT_CHANGE_DATABASE_OWNER
TargetUserNameAUDIT_DATABASE_OBJECT_GDR_EVENTAUDIT_DATABASE_OBJECT_GDR_EVENT
TargetUserNameAUDIT_DATABASE_OBJECT_TAKE_OWNERSHIP_EVENTAUDIT_DATABASE_OBJECT_TAKE_OWNERSHIP_EVENT
TargetUserNameAUDIT_DATABASE_PRINCIPAL_MANAGEMENT_EVENTAUDIT_DATABASE_PRINCIPAL_MANAGEMENT_EVENT
TargetUserNameAUDIT_DATABASE_SCOPE_GDR_EVENTAUDIT_DATABASE_SCOPE_GDR_EVENT
TargetUserNameAUDIT_SCHEMA_OBJECT_GDR_EVENTAUDIT_SCHEMA_OBJECT_GDR_EVENT
TargetUserNameAUDIT_SCHEMA_OBJECT_TAKE_OWNERSHIP_EVENTAUDIT_SCHEMA_OBJECT_TAKE_OWNERSHIP_EVENT
TargetUserNameAUDIT_SERVER_OBJECT_TAKE_OWNERSHIP_EVENTAUDIT_SERVER_OBJECT_TAKE_OWNERSHIP_EVENT
TargetUserNameAUDIT_SERVER_PRINCIPAL_MANAGEMENT_EVENTAUDIT_SERVER_PRINCIPAL_MANAGEMENT_EVENT

Code samples for TargetUserName property

The class AUDIT_SERVER_PRINCIPAL_MANAGEMENT_EVENT is abstract and serves only as a base for new classes.

Get a Class as object

Short VB Script code to get the abstract class AUDIT_SERVER_PRINCIPAL_MANAGEMENT_EVENT.
See in another language: C#, VB.Net.
'https://wutils.com/wmi/
Dim wmiClass, oProperty
Set wmiClass = GetObject( _
 "WINMGMTS:\\.\ROOT\Microsoft\SqlServer\ServerEvents\MSSQLSERVER:" + _
 "AUDIT_SERVER_PRINCIPAL_MANAGEMENT_EVENT")

'get some class property 
Wscript.Echo wmiClass.properties_("TargetUserName").Origin 'or other property name, see properties

'Check if the class is singleton
Wscript.Echo wmiClass.Path_.IsSingleton

'Get number of methods in the class
Wscript.Echo wmiClass.Methods_.Count

'List class properties
For Each oProperty In wmiClass.properties_
	'get property name and origin. Property value in the class is null, of course.
	Wscript.Echo oProperty.Name, oProperty.Origin, oProperty.Value
Next 

InstancesOf

List of all instances, wmi class AUDIT_SERVER_PRINCIPAL_MANAGEMENT_EVENT.
'https://wutils.com/wmi/
Dim oWMI, Instances, Instance

'Get base WMI object, "." means computer name (local)
Set oWMI = GetObject("WINMGMTS:\\.\ROOT\Microsoft\SqlServer\ServerEvents\MSSQLSERVER")

'Get instances of AUDIT_SERVER_PRINCIPAL_MANAGEMENT_EVENT - all instances of this class and derived classes 
Set Instances = oWMI.InstancesOf("AUDIT_SERVER_PRINCIPAL_MANAGEMENT_EVENT")


'Enumerate instances  
For Each Instance In Instances 
  'Do something with the instance
  Wscript.Echo Instance.TargetUserName 'or other property name
Next 'Instance
comments powered by Disqus
WUtils.com