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

AF SDK Reference

PIIdentityMappings Class

  • Last UpdatedNov 18, 2025
  • 7 minute read
PIIdentityMappings Class
The PIIdentityMappings collection represents the available PIIdentityMapping objects on a particular PIServer.

Inheritance Hierarchy

SystemObject
  OSIsoft.AF.PIPIIdentityMappings

Namespace:  OSIsoft.AF.PI
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182

Syntax

public sealed class PIIdentityMappings : IList<PIIdentityMapping>, 
	ICollection<PIIdentityMapping>, IEnumerable<PIIdentityMapping>, IEnumerable, 
	IList, ICollection
Public NotInheritable Class PIIdentityMappings
	Implements IList(Of PIIdentityMapping), ICollection(Of PIIdentityMapping), 
	IEnumerable(Of PIIdentityMapping), IEnumerable, IList, ICollection

Dim instance As PIIdentityMappings
public ref class PIIdentityMappings sealed : IList<PIIdentityMapping^>, 
	ICollection<PIIdentityMapping^>, IEnumerable<PIIdentityMapping^>, IEnumerable, 
	IList, ICollection
[<SealedAttribute>]
type PIIdentityMappings =  
    class
        interface IList<PIIdentityMapping>
        interface ICollection<PIIdentityMapping>
        interface IEnumerable<PIIdentityMapping>
        interface IEnumerable
        interface IList
        interface ICollection
    end

The PIIdentityMappings type exposes the following members.

Properties

Methods

  NameDescription
Public method
Add(String, String, String)
Creates a new PIIdentityMapping with the passed in name.
Public methodCode example
Add(String, String, String, PIIdentityMappingType)
Creates a new PIIdentityMapping with the passed in name.
Public method
Contains(String)
This method determines whether the collection contains a specific item referenced by name.
Public method
Contains(PIIdentityMapping)
This method determines whether the collection contains a specific item.
Public method
CopyTo
Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array.
Public method
Equals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public method
GetEnumerator
Returns an enumerator that iterates through the collection.
Public method
GetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method
IndexOf
Searches for the specified object and returns the zero-based index of the first occurrence within the entire collection.
Public method
Refresh
Refresh the collection by loading from the PIServer.
Public method
Remove(String)
Removes a PIIdentityMapping from the PI Data Archive by name
Public method
Remove(PIIdentityMapping)
Removes a PIIdentityMapping from the PI Data Archive
Public method
ToString
Returns a string that represents the current object.
(Inherited from Object.)

Extension Methods

  NameDescription
Public Extension MethodCode example
ChunkedByPIIdentityMapping
This extension method breaks up search results into chunks to make it easier to page through and process IEnumerableT collections in chunks.
(Defined by AFSDKExtension.)

Exceptions

ExceptionCondition
PIVersionNotSupportedException This exception will be generated if PIServer does not support PIIdentityMapping.

Remarks

This is the collection of available PIIdentityMapping objects on a particular PIServer. Each PIIdentityMapping object provides the mapping from a Windows user or group to a PIIdentity on the PI Data Archive.

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.

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