Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

PackageUserInformation class

Applies to Windows only

Provides information about the users of an installed package.

Important  You can't use this class in a Windows Store app.

Syntax


public sealed class PackageUserInformation

Attributes

[MarshalingBehavior(Agile)]
[Version(0x06020000)]

Members

The PackageUserInformation class has these types of members:

Methods

The PackageUserInformation class inherits methods from the Object class.

Properties

The PackageUserInformation class has these properties.

PropertyAccess typeDescription

InstallState

Read-onlyGets the install state of the package for the user.

UserSecurityId

Read-onlyGets the security identifier (SID) of the package user.

 

Remarks

To enumerate the users who have installed a package, use the PackageManager.FindUsers method.

Examples

Call the PackageManager.FindUsers method to enumerate the users who have installed a package. This example displays the information in the PackageUserInformation.UserSecurityId property.



using System.Security.Principal;

private static void DisplayPackageUsers(
    Windows.Management.Deployment.PackageManager packageManager, 
    Windows.ApplicationModel.Package package)
{
    IEnumerable<Windows.Management.Deployment.PackageUserInformation> packageUsers = 
        packageManager.FindUsers(package.Id.FullName);

    Console.Write("Users: ");

    foreach (var packageUser in packageUsers)
    {
        Console.Write("{0} ", SidToAccountName(packageUser.UserSecurityId));
    }

    Console.WriteLine();
}

private static string SidToAccountName(string sidString)
{
    SecurityIdentifier sid = new SecurityIdentifier(sidString);
    try
    {
        NTAccount account = (NTAccount)sid.Translate(typeof(NTAccount));
        return account.ToString();
    }
    catch (IdentityNotMappedException)
    {
        return sidString;
    }
}

Requirements

Minimum supported client

Windows 8 [desktop apps only]

Minimum supported server

Windows Server 2012 [desktop apps only]

Minimum supported phone

None supported

Namespace

Windows.Management.Deployment
Windows::Management::Deployment [C++]

Metadata

Windows.winmd

See also

Samples
Enumerate app packages sample
Enumerate app packages by name and publisher sample
Concepts
App packages and deployment
Reference
PackageManager

 

 

Show:
© 2014 Microsoft