Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

PIIdentityMapping Class

  • Last UpdatedNov 18, 2025
  • 8 minute read
PIIdentityMapping Class
The PIIdentityMapping object represents a mapping between Windows identity and PIIdentity on a PIServer.

Inheritance Hierarchy

SystemObject
  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

  NameDescription
Public property
Description
Read/write property that provides a description of the PIIdentityMapping.
Public property
ID
This read-only property provides a unique identifier for the PIIdentityMapping on the PIServer.
Public property
Identity
This property identifies the Name of the PIIdentity this mapping is associated with.
Public property
IdentityMappingType
This read-only property identifies the type of PIIdentityMapping. Currently, only Windows is supported.
Public property
IsDeleted
This read-only property indicates whether the object has been deleted.
Public property
IsDirty
This read-only property indicates whether the object has been modified since the last save to the PI Data Archive.
Public property
IsEnabled
This property determines if the PIIdentityMapping is enabled on the PIServer.
Public property
IsNew
This read-only property indicates whether the object has been modified since the last save to the PI Data Archive.
Public property
Name
This property defines the name of the PIIdentityMapping.
Public property
Principal
This read-only property identifies the principal of a PIIdentityMapping. For the case of Windows mapping, the Principal is a Windows SID.
Public property
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.
Public property
Server
The PIServer for this PIIdentityMapping.

Methods

  NameDescription
Public method
CheckIn
This method checks in (commits) all the changes to the object by saving the information to PI Data Archive.
Public method
CompareTo(Object)
Compares this instance with a specified Object.
Public method
CompareTo(PIIdentityMapping)
Compares this instance with a specified PIIdentityMapping.
Public method
Equals(Object)
Determines whether the specified Object is equal to the current object.
(Overrides ObjectEquals(Object).)
Public method
Equals(PIIdentityMapping)
Indicates whether the current object is equal to another object of the same type.
Public method
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.)
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method
ToString
Returns a String that represents the current object.
(Overrides ObjectToString.)

Operators

  NameDescription
Public operatorStatic member
Equality
The equality operator (==) compares its operands to determine if they are equal.
Public operatorStatic member
GreaterThan
The greater than relation operator (>) compares its operands to determine which one is greater than the other.
Public operatorStatic member
GreaterThanOrEqual
The greater than or equal relation operator (>=) compares its operands to determine which one is greater than or equal to the other.
Public operatorStatic member
Inequality
The inequality operator (!=) compares its operands to determine if they are not equal.
Public operatorStatic member
LessThan
The less than relation operator (<) compares its operands to determine which one is less than the other.
Public operatorStatic member
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];

Version Information

AFSDK

Supported in: 3.1.1, 3.1.0, 3.0.2, 3.0.1, 3.0.0, 2.10.11, 2.10.5, 2.10.0, 2.10, 2.9.5, 2.9, 2.8.5, 2.8, 2.7.5, 2.7, 2.6

See Also

TitleResults for “How to create a CRG?”Also Available in