Add Method (PIUsers collection)



The Add method creates a new PIUser object and attaches it to the Server.PIUsers collection. The method returns a reference to the PIUser object created.


object.Add Name, Description, Password, Groups, Context

The Add method syntax has these parts:

Part Description


An object expression that evaluates to a PIUsers collection obtained from a Server object.


A string representing the name for the new user.


A string containing a description to be associated with the new user.


A NamedValues collection containing names of user groups to which the new user should belong. The names can be obtained from the Server.PIGroups collection on the server.  The value portion of each NamedValue in the collection is ignored.


A string containing the password for the new user.


An optional string containing the name of a PIContext to associate with the new user. A list of current contexts can be obtained from the Server.PIContexts collection.


Adding a user to the server will only succeed if the caller has write access to the user database on the server. This access is controlled through server specific means to maintain an environment with the desired level of security.


Trappable Errors

In addition to generic errors (such as Out of Memory), the following errors may occur:

Error Description


Caller does not have sufficient privilege to add a new PIUser.


The user name may not be blank.


The passed context string does not exist on the server.

pseUSEREXISTS A user by this name already exists on the server.
pseUSERINSTANTIATE Unable to create a PIUser object in memory. May be out of memory.


Unable to create a PIUser on the server.
pseGROUPNOTFOUND One of the groups passed does not exist. See the error description for more information.

Enabling Operational Intelligence