YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Determining PI User Group Options · View
sohojinks
#1 Posted : Saturday, September 05, 2009 4:39:29 PM
Rank: Member
Groups: Member

Joined: 7/30/2009
Posts: 11
Location: Rochester, NY, USA
Hello,


Does anyone know of a way to determine the user group of the current user logged into ProcessBook using VBA?

I'd like to perform a single action if the user is an operator, if the user is an engineer I'd like to perform an extra step.

Any ideas?
Sponsor  
 

OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System.
We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ  or contact OSIsoft vCampus for more details.
RJK Solutions
#2 Posted : Sunday, September 06, 2009 4:32:21 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 617
Location: Cheshire, United Kingdom.
Well you have come to the right place for an answer... :-)
The answer is yes.

Something to consider, a PI User can belong to one or more PI Groups so you will need to loop through the PI Groups for a PI User and check for a particular group.
For a PISDK.Server connection there is a property "CurrentUser" that returns a string of the PI User associated with the connection - either by a PI User login (default user) or via a PI Trust.

Here is an example:
Code:

Private Srv As PISDK.Server

Sub CheckPIUser()

' Set the PISDK.Server object to the required PI Collective/Server
'...

If Srv.Connected Then
    If Not Srv.CurrentUser = "" Then
        Dim PU As PIUser, PG As PIGroup
        Set PU = Srv.PIUsers(Srv.CurrentUser)
            ' A PI user can belong to one or more groups.
            ' Loop through them and perform your checks
            For Each PG In PU.PIGroups
                ' Check the group name...
                Debug.Print PG.Name
            Next PG
        Set PU = Nothing
    End If
End If

End Sub


Enjoy!

Rhys.
Principal Consultant
Real-Time Data Management @ Wipro Technologies
sohojinks
#3 Posted : Sunday, September 06, 2009 5:58:24 PM
Rank: Member
Groups: Member

Joined: 7/30/2009
Posts: 11
Location: Rochester, NY, USA
Thanks again!
OlJo69
#4 Posted : Thursday, April 21, 2011 2:07:56 PM
Rank: Newbie
Groups: Member

Joined: 3/4/2011
Posts: 6
Location: France
Hi Forum !

It seems that on PI Server 2010 when accessing to the "Srv.CurrentUser" what comes back is a string containing all the PIIdentities that belongs to the connection separated by a pipe. (In my case: "piadmins | piusers | PIWorld")
I'm connecting with a trust as the PIUser named "PIAdmin"(which doesn't even appear in the string returned just before).

Does anyone know a way to get these PIIdentities in a collection which would be better to check for a specific identity than using Instr() ?

Any ideas would be much appreciated.
Thanks in advance !
sohojinks
#5 Posted : Thursday, April 21, 2011 2:37:08 PM
Rank: Member
Groups: Member

Joined: 7/30/2009
Posts: 11
Location: Rochester, NY, USA
If I understand correctly, I think the following will get you what you need.

Dim PU As PIUser
Set PU = SRV.PIUsers(SRV.CurrentUser)

Select Case PU.Name
Case "piadmin"
...
Case else
...
End Select
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.