PIDatabaseSecurity.GetSecurityRights Method (String)
- Last UpdatedNov 18, 2025
- 4 minute read
- PI System
- AF SDK 2024 R2
- Developer
This method parses the SecurityString 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 securityString )
Public Shared Function GetSecurityRights ( securityString As String ) As IList(Of KeyValuePair(Of String, AFSecurityRights)) Dim securityString As String Dim returnValue As IList(Of KeyValuePair(Of String, AFSecurityRights)) returnValue = PIDatabaseSecurity.GetSecurityRights(securityString)
public: static IList<KeyValuePair<String^, AFSecurityRights>>^ GetSecurityRights( String^ securityString )
static member GetSecurityRights : securityString : string -> IList<KeyValuePair<string, AFSecurityRights>>
Parameters
- securityString
- Type: SystemString
The security string to be parsed.
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 PIPoint security attribute.
Example of securityString input parameter:
“piadmin: A(r,w) | piadmins: A(w) | piworld: A()”
This will result into three AFSecurityRights where the keys are: "piadmin" (ReadWrite access), "piadmins" (Write access), and "piworld" (None 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.