I understand you are about to develop a custom PISDKUtility. What's wrong with the one OSIsoft offers?
myServer.DefaultUser = "Hugo"
I'm not developing a custom PISDKUtility but something that we will be using to automatically configure the installations of our users.
I think my explanation was unclear. If you go to
1. PI SDK Utility
2. Connections menu
you will see that there is a group box "Default Server Settings". Inside this group box there is a checkbox with the caption "Override the default for current user (<username>)".
Checking this box allows the user to have an individual user-account dependent setting of his default server that is needed in case multiple users are workin on the same client with different default servers.
I'd like to activate this from my application (basically it's only adding a registy value to HKEY_CURRENT_USER\Software\PISystem\PI-SDK\1.0 / DWORD with name DEFSERVERBYUSER and value 1... But I'd like to do that using the PISDK and not by registry manipulation!
I doubt this information is available through PI SDK and I strongly recommend not directly accessing Windows Registry. You may be missing something like i.e. the additional string value "DefaultServer" that is storing the default server for a particular user when DEFSERVBYUSER is 1.
The default username is used for explicit user login. We do not recommend this method at all because username and password are transferred unencrypted over the network.
With your attempt to store the default username in dependency of the user connected you are using Windows security. Wouldn't it be a better approach to create mappings?