PIIdentityMapping Class
- Last UpdatedNov 18, 2025
- 8 minute read
- PI System
- AF SDK 2024 R2
- Developer
The PIIdentityMapping object represents a mapping between Windows identity and PIIdentity on a PIServer.

Inheritance Hierarchy
SystemObject
OSIsoft.AF.PIPIIdentityMapping
OSIsoft.AF.PIPIIdentityMapping
Namespace: OSIsoft.AF.PI
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public sealed class PIIdentityMapping : IComparable, IComparable<PIIdentityMapping>, IEquatable<PIIdentityMapping>
Public NotInheritable Class PIIdentityMapping Implements IComparable, IComparable(Of PIIdentityMapping), IEquatable(Of PIIdentityMapping) Dim instance As PIIdentityMapping
public ref class PIIdentityMapping sealed : IComparable, IComparable<PIIdentityMapping^>, IEquatable<PIIdentityMapping^>
[<SealedAttribute>] type PIIdentityMapping = class interface IComparable interface IComparable<PIIdentityMapping> interface IEquatable<PIIdentityMapping> end
The PIIdentityMapping type exposes the following members.
Properties
| Name | Description | |
|---|---|---|
| Description |
Read/write property that provides a description of the PIIdentityMapping.
| |
| ID |
This read-only property provides a unique identifier for the PIIdentityMapping on the PIServer.
| |
| Identity |
This property identifies the Name of the PIIdentity this mapping is associated with.
| |
| IdentityMappingType |
This read-only property identifies the type of PIIdentityMapping. Currently, only Windows is supported.
| |
| IsDeleted |
This read-only property indicates whether the object has been deleted.
| |
| IsDirty |
This read-only property indicates whether the object has been modified since the last save to the PI Data Archive.
| |
| IsEnabled |
This property determines if the PIIdentityMapping is enabled on the PIServer.
| |
| IsNew |
This read-only property indicates whether the object has been modified since the last save to the PI Data Archive.
| |
| Name |
This property defines the name of the PIIdentityMapping.
| |
| Principal |
This read-only property identifies the principal of a PIIdentityMapping. For the case of Windows mapping, the Principal is a Windows SID.
| |
| PrincipalName |
This read-only property identifies the principal name of a PIIdentityMapping. For the case of Windows mapping, the PrincipalName is the Windows Account Name.
| |
| Server |
The PIServer for this PIIdentityMapping.
|
Methods
| Name | Description | |
|---|---|---|
| CheckIn |
This method checks in (commits) all the changes to the object by saving the information to PI Data Archive.
| |
| CompareTo(Object) |
Compares this instance with a specified Object.
| |
| CompareTo(PIIdentityMapping) |
Compares this instance with a specified PIIdentityMapping.
| |
| Equals(Object) |
Determines whether the specified Object is equal to the current object.
(Overrides ObjectEquals(Object).) | |
| Equals(PIIdentityMapping) |
Indicates whether the current object is equal to another object of the same type.
| |
| GetHashCode |
Gets the hash code for this instance of the object which is suitable for use in hashing
algorithms and data structures like a hash table.
(Overrides ObjectGetHashCode.) | |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| ToString |
Returns a String that represents the current object.
(Overrides ObjectToString.) |
Operators
| Name | Description | |
|---|---|---|
| Equality |
The equality operator (==) compares its operands to determine if they are equal.
| |
| GreaterThan |
The greater than relation operator (>) compares its operands to determine
which one is greater than the other.
| |
| GreaterThanOrEqual |
The greater than or equal relation operator (>=) compares its operands to determine
which one is greater than or equal to the other.
| |
| Inequality |
The inequality operator (!=) compares its operands to determine if they are not equal.
| |
| LessThan |
The less than relation operator (<) compares its operands to determine
which one is less than the other.
| |
| LessThanOrEqual |
The less than or equal relation operator (<=) compares its operands to determine
which one is less than or equal to the other.
|
Remarks
A mapping creates an association between an entity on Windows (such as an Active Directory Group) with a PIIdentity on the PI Data Archive.
An identity may be of type PI identity, PI User, or PI Group.
Examples
// Get the PIIdentityMappings from the PIServer on the local computer PISystems myPISystems = new PISystems(); PISystem myPISystem = myPISystems.DefaultPISystem; PIServer myPIServer = PIServer.FindPIServer(myPISystem, piServerName); // Display information about each PIIdentityMapping and its properties PIIdentityMappings mappings = myPIServer.IdentityMappings; Console.WriteLine("Found {0} identity mappings", mappings.Count); foreach (PIIdentityMapping mapping in mappings) { Console.WriteLine(mapping.Name); Console.WriteLine(" ID: {0}", mapping.ID); Console.WriteLine(" Description: {0}", mapping.Description); Console.WriteLine(" Principal: {0}", mapping.Principal); Console.WriteLine(" PrincipalName: {0}", mapping.PrincipalName); Console.WriteLine(" Identity: {0}", mapping.Identity); Console.WriteLine(" IdentityMappingType: {0}", mapping.IdentityMappingType); Console.WriteLine(" IsEnabled: {0}", mapping.IsEnabled); Console.WriteLine(); } // Add a mapping, if it does not yet exist. string newMapName = "PIIdentityMappingTestExample"; string mapDomainUser = QAConfig.TestAccountNoMapping; string identity = "piusers"; PIIdentityMapping newMap; if (!mappings.Contains(newMapName)) { // Note that adding or editing a mapping requires 'CheckIn' in order to commit it to the PI Data Archive. newMap = mappings.Add(newMapName, mapDomainUser, identity); newMap.CheckIn(); } else newMap = mappings[newMapName]; Console.WriteLine(newMap.Name); Console.WriteLine(" ID: {0}", newMap.ID); Console.WriteLine(" Description: {0}", newMap.Description); Console.WriteLine(" Principal: {0}", newMap.Principal); Console.WriteLine(" PrincipalName: {0}", newMap.PrincipalName); Console.WriteLine(" Identity: {0}", newMap.Identity); Console.WriteLine(" IdentityMappingType: {0}", newMap.IdentityMappingType); Console.WriteLine(" IsEnabled: {0}", newMap.IsEnabled); Console.WriteLine(); // Edit a mapping. newMap.Description = "This is a PIIdentityMapping for Test Example"; newMap.CheckIn(); Console.WriteLine(newMap.Name); Console.WriteLine(" Description: {0}", newMap.Description); Console.WriteLine(); // Delete a mapping. // Note that the 'Remove' call will be directly committed to the PI Data Archive. mappings.Remove(newMap);
' Get the PIIdentityMappings from the PIServer on the local computer Dim myPISystems As New PISystems Dim myPISystem As PISystem = myPISystems.DefaultPISystem Dim myPIServer As PIServer = PIServer.FindPIServer(myPISystem, piServerName) ' Display information about each PIIdentityMapping and its properties Dim mappings As PIIdentityMappings = myPIServer.IdentityMappings Console.WriteLine("Found {0} identity mappings", mappings.Count) For Each mapping As PIIdentityMapping In mappings Console.WriteLine(mapping.Name) Console.WriteLine(" ID: {0}", mapping.ID) Console.WriteLine(" Description: {0}", mapping.Description) Console.WriteLine(" Principal: {0}", mapping.Principal) Console.WriteLine(" PrincipalName: {0}", mapping.PrincipalName) Console.WriteLine(" Identity: {0}", mapping.Identity) Console.WriteLine(" IdentityMappingType: {0}", mapping.IdentityMappingType) Console.WriteLine(" IsEnabled: {0}", mapping.IsEnabled) Console.WriteLine() Next 'Add a mapping, if it does not yet exist. Dim newMapName As String = "PIIdentityMappingTestExample" Dim mapDomainUser As String = QAConfig.TestAccountNoMapping Dim identity As String = "piusers" Dim newMap As PIIdentityMapping If (Not mappings.Contains(newMapName)) Then 'Note that adding or editing a mapping requires 'CheckIn' in order to commit it to the PI Data Archive. newMap = mappings.Add(newMapName, mapDomainUser, identity) newMap.CheckIn() Else newMap = mappings(newMapName) End If Console.WriteLine(newMap.Name) Console.WriteLine(" ID: {0}", newMap.ID) Console.WriteLine(" Description: {0}", newMap.Description) Console.WriteLine(" Principal: {0}", newMap.Principal) Console.WriteLine(" PrincipalName: {0}", newMap.PrincipalName) Console.WriteLine(" Identity: {0}", newMap.Identity) Console.WriteLine(" IdentityMappingType: {0}", newMap.IdentityMappingType) Console.WriteLine(" IsEnabled: {0}", newMap.IsEnabled) Console.WriteLine() 'Edit a mapping. newMap.Description = "This is a PIIdentityMapping for Test Example" newMap.CheckIn() Console.WriteLine(newMap.Name) Console.WriteLine(" Description: {0}", newMap.Description) Console.WriteLine() 'Delete a mapping. 'Note that the 'Remove' call will be directly committed to the PI Data Archive. mappings.Remove(newMap)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
// Get the PIIdentityMappings from the PIServer on the local computer PISystems myPISystems = new PISystems(); PISystem myPISystem = myPISystems.DefaultPISystem; PIServer myPIServer = PIServer.FindPIServer(myPISystem, piServerName); // Add a mapping, if it does not yet exist. string newMapName = @"Windows\S-1-5-32-544"; string mapAIMServerAdministrators = @"Windows\S-1-5-32-544"; string identity = "piadmins"; PIIdentityMappings mappings = myPIServer.IdentityMappings; PIIdentityMapping newMap; if (!mappings.Contains(newMapName)) { // Note that adding or editing a mapping requires 'CheckIn' in order to commit it to the PI Data Archive. newMap = mappings.Add(newMapName, mapAIMServerAdministrators, identity, PIIdentityMappingType.Role); newMap.CheckIn(); } else newMap = mappings[newMapName]; Console.WriteLine(newMap.Name); Console.WriteLine(" ID: {0}", newMap.ID); Console.WriteLine(" Description: {0}", newMap.Description); Console.WriteLine(" Principal: {0}", newMap.Principal); Console.WriteLine(" PrincipalName: {0}", newMap.PrincipalName); Console.WriteLine(" Identity: {0}", newMap.Identity); Console.WriteLine(" IdentityMappingType: {0}", newMap.IdentityMappingType); Console.WriteLine(" IsEnabled: {0}", newMap.IsEnabled); Console.WriteLine(); myPIServer.Connect(TestAccountAccessToken); // Create a ClientCredential Mapping newMap = null; if (!mappings.Contains(TestClientId)) { // Note that adding or editing a mapping requires 'CheckIn' in order to commit it to the PI Data Archive. newMap = mappings.Add(TestClientId, TestClientId, identity, PIIdentityMappingType.ClientCredential); newMap.CheckIn(); } else newMap = mappings[TestClientId];