aaApi_IsUserConnected questions

aaApi_IsUserConnected is documented "This function requires administrative privileges."

is there an alternative method to verify the connection that does not require administrative privileges?

Also, when I do try as administrator, the function always seems to return false.

bool PwLogin::login(PwLoginInfo &info)
{
   const LONG_PTR res = aaApi_LoginDlgExt
   (
       info.hWndParent, 
       info.mTitle, 
       info.ulFlags, 
       info.mDataSource.data(), 
       info.mDataSource.size(), 
       info.mUsername, 
       info.mPassword, 
       info.mSchema
   );
    if (res == IDOK)
    {
        info.userID = aaApi_GetCurrentUserId();
        if (info.userID == -1)
            return false;
        if (aaApi_SelectUser(info.userID) == TRUE)
            info.mUsername = aaApi_GetUserStringProperty(USER_PROP_NAME, 0);
    }
    return aaApi_IsUserConnected(info.userID) == TRUE;
}

the result is Connected = false, user id = 1,  name = Administrator.

the input is all null/empty except hWndParent

Thank you

Parents
  • I suspect that the "problem" you are having is more about "words get in the way", than what you are coding.  When using the PW APIs, it matters which login "mode" you use to connect.  Think of it as the difference between logging into PW Explorer vs. PW Administrator.  You have to be an Administrator to log into the PW Administrator client, and you can only do some actions using that tool.   Non-administrators cannot log into the PW Administrator client and therefor they do not have access to some functions (like create users).

    Now, on the other end of this example, a PW Administrator can log into PW Explorer, but that administrator can't do some functions, like add new users, from that tool.  This separation is generally separated in the API functions as well. For some function to "work", you need to be an administrator AND you must have used the "administrator" type of login for your session.

    What are you passing for your info.ulFlags?  You might have to set the ALOGIN_ADMINISTRATIVE flag, which of course means that this will limit the users who can actually login to just users who are administrators.

    Answer Verified By: Daniel Marcotte 

  • Hi Dan,

    the login would be for non administrative users, but because their session in our application may last hours, I thought it would be appropriate to verify that the user is still logged in before issuing a command. I.e.

    if(aaApi_IsUserConnected())
    {
     //do something in projectwise
    }

Reply Children