Click or drag to resize
OSIsoft, LLC

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: 2.10.6.195
Syntax
public sealed class PIIdentityMappings : IList<PIIdentityMapping>, 
	ICollection<PIIdentityMapping>, IEnumerable<PIIdentityMapping>, IEnumerable, 
	IList, ICollection

The PIIdentityMappings type exposes the following members.

Properties
Methods
  NameDescription
Public methodAdd
Creates a new PIIdentityMapping with the passed in name.
Public methodContains(String)
This method determines whether the collection contains a specific item referenced by name.
Public methodContains(PIIdentityMapping)
This method determines whether the collection contains a specific item.
Public methodCopyTo
Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetEnumerator
Returns an enumerator that iterates through the collection.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIndexOf
Searches for the specified object and returns the zero-based index of the first occurrence within the entire collection.
Public methodRefresh
Refresh the collection by loading from the PIServer.
Public methodRemove(String)
Removes a PIIdentityMapping from the PI Data Archive by name
Public methodRemove(PIIdentityMapping)
Removes a PIIdentityMapping from the PI Data Archive
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
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 = "osi\\AFTeamRDA";
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);
Version Information

AFSDK

Supported in: 2.10.5, 2.10, 2.9.5, 2.9, 2.8.5, 2.8, 2.7.5, 2.7, 2.6
See Also
Enabling Operational Intelligence