Hi,
I'm trying to get user id in the function uaprovider_demo_session_hook(enum uasession_event_type type, uint32_t channel_id, struct uasession_session *session) in server_demo by session->user_ctx.uid. But it always return 0 even I use the user "john" as username.
Is that the correct way to get the user id when session is creating?
Thanks.
Get user id when hook for monitoring session events
Moderator: uasdkhpc
-
- Full Member
- Posts: 5
- Joined: 18 May 2018, 09:54
- Support Team
- Hero Member
- Posts: 3078
- Joined: 18 Mar 2011, 15:09
Re: Get user id when hook for monitoring session events
Hello Annie,
I just tried it and it works for me.
I added the following code to the example:
Please ensure that you have enabled UA_AUTHORIZATION_SUPPORT and that you entered the correct password.
When starting the server by filtering the trace
I get this output:
I just tried it and it works for me.
I added the following code to the example:
Code: Select all
case UASESSION_EVENT_ACTIVATESESSION:
TRACE_INFO(TRACE_FAC_PROVIDER, "A session with session_id=%u was activated on channel with channel_id=%u.\n", session->session_id, channel_id);
#ifdef UA_AUTHORIZATION_SUPPORT
TRACE_INFO(TRACE_FAC_PROVIDER, "uid=%u.\n", session->user_ctx.uid);
#endif
break;
When starting the server by filtering the trace
Code: Select all
./uaserverhp -d 4 -f 512
Code: Select all
I|15:11:41.558771|10844| A session with session_id=3166477824 was activated on channel with channel_id=3025033216.
I|15:11:41.558789|10844| uid=3.
Best regards
Unified Automation Support Team
Unified Automation Support Team
-
- Full Member
- Posts: 5
- Joined: 18 May 2018, 09:54
Re: Get user id when hook for monitoring session events
It works. Thanks.