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

AF SDK Reference

PIIdentity Class

  • Last UpdatedNov 18, 2025
  • 8 minute read
PIIdentity Class
The PIIdentity object represents an identity on a PIServer.

Inheritance Hierarchy

SystemObject
  OSIsoft.AF.PIPIIdentity

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

Syntax

public sealed class PIIdentity : IComparable, 
	IComparable<PIIdentity>, IEquatable<PIIdentity>
Public NotInheritable Class PIIdentity
	Implements IComparable, IComparable(Of PIIdentity), 
	IEquatable(Of PIIdentity)

Dim instance As PIIdentity
public ref class PIIdentity sealed : IComparable, 
	IComparable<PIIdentity^>, IEquatable<PIIdentity^>
[<SealedAttribute>]
type PIIdentity =  
    class
        interface IComparable
        interface IComparable<PIIdentity>
        interface IEquatable<PIIdentity>
    end

The PIIdentity type exposes the following members.

Properties

  NameDescription
Public property
AllowExplicitLogin
This property determines if the PIIdentity can be used for an explicit login.
Public property
AllowMappings
This property determines if the PIIdentity can be used in a Mapping.
Public property
AllowTrusts
This property determines if the PIIdentity can be used in a Trust.
Public property
CanDelete
This property determines if the PIIdentity can be deleted on the PIServer.
Public property
Description
Read/write property that provides a description of the PIIdentity.
Public property
ID
Read-only property that provides a unique identifier for the PIIdentity on the PIServer.
Public property
IdentityType
This property identifies the type of PIIdentity.
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 PIIdentity is enabled on the PIServer.
Public property
IsNew
This read-only property indicates whether the object has been added into the collection but has not been saved to the PI Data Archive.
Public property
Name
This property defines the name of the PIIdentity.
Public property
Server
The PIServer for this PIIdentity.

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(PIIdentity)
Compares this instance with a specified PIIdentity.
Public method
Equals(Object)
Determines whether the specified Object is equal to the current object.
(Overrides ObjectEquals(Object).)
Public method
Equals(PIIdentity)
Indicates whether the current object is equal to another object of the same type.
Public method
GetGroupMemberships
Get all the PI Groups associated with this PIUser identity.
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
GetPIIdentityMappings
Get all the PIIdentityMapping objects associated with this identity.
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method
GetUserMemberships
Get all the PI Users associated with this PIGroup identity.
Public method
SetGroupMemberships
Set the PI Groups associated with this PIUser identity.
Public method
SetPassword
Set the password associated with this PIUser identity.
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 PIIdentity represents a PI Identity, PI User or PI Group on a PIServer. A PI Identity is used to define an authentication path to the server. Once authenticated, access permissions on PI Data Archive objects define authorization against all three types of identities: PI Identities, PI Users, and PI Groups.

Examples

// Get the PIIdentities 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 PIIdentity and its properties
PIIdentities identities = myPIServer.Identities;
Console.WriteLine("Found {0} identities", identities.Count);
foreach (PIIdentity identity in identities)
{
    Console.WriteLine(identity.Name);
    Console.WriteLine("  IdentityType: {0}", identity.IdentityType);
    Console.WriteLine("  Description: {0}", identity.Description);
    Console.WriteLine("  AllowExplicitLogin: {0}", identity.AllowExplicitLogin);
    Console.WriteLine("  AllowMappings: {0}", identity.AllowMappings);
    Console.WriteLine("  AllowTrusts: {0}", identity.AllowTrusts);
    Console.WriteLine("  IsEnabled: {0}", identity.IsEnabled);
    Console.WriteLine();
}

// Add an identity of PIIdentity type, if it does not yet exist.
string newIdName = "PIIdentityTestExample";
PIIdentity newId;
if (!identities.Contains(newIdName))
{
    // Note that adding or editing an identity requires 'CheckIn' in order to commit it to the PI Data Archive.
    newId = identities.Add(newIdName, PIIdentityType.PIIdentity);
    newId.CheckIn();
}
else 
    newId = identities[newIdName];

Console.WriteLine(newId.Name);
Console.WriteLine("  IdentityType: {0}", newId.IdentityType);
Console.WriteLine("  Description: {0}", newId.Description);
Console.WriteLine("  AllowExplicitLogin: {0}", newId.AllowExplicitLogin);
Console.WriteLine("  AllowMappings: {0}", newId.AllowMappings);
Console.WriteLine("  AllowTrusts: {0}", newId.AllowTrusts);
Console.WriteLine("  IsEnabled: {0}", newId.IsEnabled);
Console.WriteLine();

// Edit an identity.
newId.Description = "This is a PIIdentity for Test Example";
newId.CheckIn();

Console.WriteLine(newId.Name);
Console.WriteLine("  Description: {0}", newId.Description);
Console.WriteLine();

// Delete an identity. 
// Note that the 'Remove' call will be directly committed to the PI Data Archive.
identities.Remove(newId);
' Get the PIIdentities 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 PIIdentity and its properties
Dim identities As PIIdentities = myPIServer.Identities
Console.WriteLine("Found {0} identities", identities.Count)
For Each identity As PIIdentity In identities
    Console.WriteLine(identity.Name)
    Console.WriteLine("  IdentityType: {0}", identity.IdentityType)
    Console.WriteLine("  Description: {0}", identity.Description)
    Console.WriteLine("  AllowExplicitLogin: {0}", identity.AllowExplicitLogin)
    Console.WriteLine("  AllowMappings: {0}", identity.AllowMappings)
    Console.WriteLine("  AllowTrusts: {0}", identity.AllowTrusts)
    Console.WriteLine("  IsEnabled: {0}", identity.IsEnabled)
    Console.WriteLine()
Next

' Add an identity of PIIdentity type, if it does not yet exist.
Dim newIdName As String = "PIIdentityTestExample"
Dim newId As PIIdentity
If (Not identities.Contains(newIdName)) Then
    ' Note that adding or editing an identity requires 'CheckIn' in order to commit it to the PI Data Archive.
    newId = identities.Add(newIdName, PIIdentityType.PIIdentity)
    newId.CheckIn()
Else
    newId = identities(newIdName)
End If

Console.WriteLine(newId.Name)
Console.WriteLine("  IdentityType: {0}", newId.IdentityType)
Console.WriteLine("  Description: {0}", newId.Description)
Console.WriteLine("  AllowExplicitLogin: {0}", newId.AllowExplicitLogin)
Console.WriteLine("  AllowMappings: {0}", newId.AllowMappings)
Console.WriteLine("  AllowTrusts: {0}", newId.AllowTrusts)
Console.WriteLine("  IsEnabled: {0}", newId.IsEnabled)
Console.WriteLine()

' Edit an identity.
newId.Description = "This is a PIIdentity for Test Example"
newId.CheckIn()

Console.WriteLine(newId.Name)
Console.WriteLine("  Description: {0}", newId.Description)
Console.WriteLine()

' Delete an identity. 
' Note that the 'Remove' call will be directly committed to the PI Data Archive.
identities.Remove(newId)

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