PIIdentities Class
- Last UpdatedJan 12, 2026
- 6 minute read
- PI System
- AF SDK 3.2.0
- Developer

Inheritance Hierarchy
SystemObject
OSIsoft.AF.PIPIIdentities
OSIsoft.AF.PIPIIdentities
Namespace: OSIsoft.AF.PI
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.2.0.7
Syntax
public sealed class PIIdentities : IList<PIIdentity>, ICollection<PIIdentity>, IEnumerable<PIIdentity>, IEnumerable, IList, ICollection
Public NotInheritable Class PIIdentities Implements IList(Of PIIdentity), ICollection(Of PIIdentity), IEnumerable(Of PIIdentity), IEnumerable, IList, ICollection Dim instance As PIIdentities
public ref class PIIdentities sealed : IList<PIIdentity^>, ICollection<PIIdentity^>, IEnumerable<PIIdentity^>, IEnumerable, IList, ICollection
[<SealedAttribute>] type PIIdentities = class interface IList<PIIdentity> interface ICollection<PIIdentity> interface IEnumerable<PIIdentity> interface IEnumerable interface IList interface ICollection end
The PIIdentities type exposes the following members.
Properties
| Name | Description | |
|---|---|---|
| Count |
Gets the number of items actually contained in the collection.
| |
| ItemInt32 |
Gets or sets the item at the specified index.
| |
| ItemString |
Returns the specified object from the collection by name.
| |
| Server |
The PIServer for this PIIdentities collection.
|
Methods
| Name | Description | |
|---|---|---|
| Add |
Creates a new PIIdentity with the passed in name.
| |
| Contains(String) |
This method determines whether the collection contains a specific item referenced by name.
| |
| Contains(PIIdentity) |
This method determines whether the collection contains a specific item.
| |
| CopyTo |
Copies the entire collection to a compatible one-dimensional Array,
starting at the specified index of the target array.
| |
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
| GetEnumerator |
Returns an enumerator that iterates through the collection.
| |
| GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| IndexOf |
Searches for the specified object and returns the zero-based index of the first
occurrence within the entire collection.
| |
| Refresh |
Refresh the collection by loading from the PIServer.
| |
| Remove(String) |
Removes a PIIdentity from the PI Data Archive by name
| |
| Remove(PIIdentity) |
Removes a PIIdentity from the PI Data Archive
| |
| ToString | Returns a string that represents the current object. (Inherited from Object.) |
Extension Methods
| Name | Description | |
|---|---|---|
| ChunkedByPIIdentity |
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
| Exception | Condition |
|---|---|
| PIVersionNotSupportedException | This exception will be generated if PIServer does not support PIIdentity. |
Remarks
The PIIdentities collection consist of the PI Identities, PI Users and PI Groups
that are configured on a PIServer. PI Identities are used to define authentication
methods 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);