PIDatabaseSecurity.GetSecurityRights Method (String, String, String)
- Last UpdatedNov 18, 2025
- 4 minute read
- PI System
- AF SDK 2024 R2
- Developer
This method convert the legacy Access Permission model (prior to PI 3.4.380) into a collection of AFSecurityRights where the key is
the name of a PI identity, user, or group.
Namespace: OSIsoft.AF.PI
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public static IList<KeyValuePair<string, AFSecurityRights>> GetSecurityRights( string owner, string group, string accessRules )
Public Shared Function GetSecurityRights ( owner As String, group As String, accessRules As String ) As IList(Of KeyValuePair(Of String, AFSecurityRights)) Dim owner As String Dim group As String Dim accessRules As String Dim returnValue As IList(Of KeyValuePair(Of String, AFSecurityRights)) returnValue = PIDatabaseSecurity.GetSecurityRights(owner, group, accessRules)
public: static IList<KeyValuePair<String^, AFSecurityRights>>^ GetSecurityRights( String^ owner, String^ group, String^ accessRules )
static member GetSecurityRights : owner : string * group : string * accessRules : string -> IList<KeyValuePair<string, AFSecurityRights>>
Parameters
- owner
- Type: SystemString
The name of the security owner associated with the returned security rights. - group
- Type: SystemString
The name of the security group associated with the returned security rights. - accessRules
- Type: SystemString
The access rules for the returned security rights.
Return Value
Type: IListKeyValuePairString, AFSecurityRightsReturns a collection of AFSecurityRights where the key is the name of a PI identity, user, or group.
Remarks
This method can also be used to obtain AFSecurityRights collection from legacy PIPoint security attribute.
Example of owner, group, and accessRules input parameters:
Owner: “piadmin”, Group: “piadmin”, Access: “o:rw g:r w:r”
This will result into three AFSecurityRights where the keys are: "piadmin" (ReadWrite access), "piadmin" (Read access), and "piworld" (Read access).
Examples
// Get the PIServer PISystems myPISystems = new PISystems(); PISystem myPISystem = myPISystems.DefaultPISystem; PIServer myPIServer = PIServer.FindPIServer(myPISystem, piServerName); // Get SecurityRights from Point Security PIPoint point; if (!PIPoint.TryFindPIPoint(myPIServer, "MyTestPoint#1", out point)) { point = myPIServer.CreatePIPoint("MyTestPoint#1"); } IDictionary<string, object> securityAttributes = null; securityAttributes = point.GetAttributes(PICommonPointAttributes.PointOwner, PICommonPointAttributes.PointGroup, PICommonPointAttributes.PointAccess, PICommonPointAttributes.PointSecurity); IList<KeyValuePair<string, AFSecurityRights>> securityRights; object securityString; //PIServer older than 3.4.380.x does not have ptsecurity attribute. if (securityAttributes.TryGetValue("ptsecurity", out securityString)) { //PIServer is 3.4.380.x or later. //GetSecurityRights through ptsecurity. securityRights = PIDatabaseSecurity.GetSecurityRights(securityString.ToString()); } else { //PIServer is older than 3.4.380.x. //GetSecurityRights through ptowner, ptgroup, and ptaccess. securityRights = PIDatabaseSecurity.GetSecurityRights(securityAttributes["ptowner"].ToString(), securityAttributes["ptgroup"].ToString(), securityAttributes["ptaccess"].ToString()); } //Display the SecurityRights Console.WriteLine(String.Format("SecurityRights for {0} Point Security", point.Name)); foreach (var securityRight in securityRights) { Console.WriteLine(" Identity = {0}, SecurityRight = {1}", securityRight.Key, securityRight.Value); Console.WriteLine(); }
' Get the PIServer Dim myPISystems As PISystems = New PISystems() Dim myPISystem As PISystem = myPISystems.DefaultPISystem Dim myPIServer As PIServer = PIServer.FindPIServer(myPISystem, piServerName) ' Get SecurityRights from Point Security Dim point As PIPoint = Nothing If Not PIPoint.TryFindPIPoint(myPIServer, "MyTestPoint#1", point) Then point = myPIServer.CreatePIPoint("MyTestPoint#1") End If Dim securityAttributes As IDictionary(Of String, Object) securityAttributes = point.GetAttributes(PICommonPointAttributes.PointOwner, PICommonPointAttributes.PointGroup, PICommonPointAttributes.PointAccess, PICommonPointAttributes.PointSecurity) Dim securityRights As IList(Of KeyValuePair(Of String, AFSecurityRights)) Dim securityString As Object = Nothing 'PIServer older than 3.4.380.x does not have ptsecurity attribute. If securityAttributes.TryGetValue("ptsecurity", securityString) Then 'PIServer is 3.4.380.x or later. 'GetSecurityRights through ptsecurity. securityRights = PIDatabaseSecurity.GetSecurityRights(securityString.ToString()) Else 'PIServer is older than 3.4.380.x. 'GetSecurityRights through ptowner, ptgroup, and ptaccess. securityRights = PIDatabaseSecurity.GetSecurityRights(securityAttributes("ptowner").ToString(), securityAttributes("ptgroup").ToString(), securityAttributes("ptaccess").ToString()) End If 'Display the SecurityRights Console.WriteLine(String.Format("SecurityRights for {0} Point Security", point.Name)) For Each securityRight As KeyValuePair(Of String, AFSecurityRights) In securityRights Console.WriteLine(" Identity = {0}, SecurityRight = {1}", securityRight.Key, securityRight.Value) Console.WriteLine() Next
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.