get current user with BWS

Hello,
I use the BWS and must get the current user.
With RpGetCurrentUserName I get NULL.

How I become the correct User?

thx,
Frank

Frank,

You have to use the Advanced WEB Server in order to use RpGetCurrentUserName. In my case, I need to evaluate the user level whenever a page is served, so from the first function executed on the page I call (the function specified in RpPageHeader) I call the function below.
Hope it helps.

Ivica Eftimovski


extern BOOLEAN customizeAceGetInterfaceAddrInfo(const char * ifname, aceAddrInfo * addr_info);
extern char * RpGetCurrentUserName(void *theTaskDataPtr);

unsigned int CheckCurrentUserRealm(void)
{
void *httpServerDataPtr;
char *curUserName;
char password[NASYSACC_STRLEN_PASSWORD + 1];

httpServerDataPtr = RpHSGetServerData();

curUserName = RpGetCurrentUserName(httpServerDataPtr);

if (curUserName == 0)
	return 0;

return NAgetSysAccess(curUserName, password, NULL);

}

Ivica,

Thank you for publishing this answer. It has been very useful for me.

I was using the RpGetCurrentRealm() function, as pointed out by the Digi support, but it does not work for me. I try with users with different privileges but it always return the same value (3). I am enclosing the code at the end of the message.

But your solutions work perfectly well.

Thanx again,
Jose


extern rpAccess RpGetCurrentRealm(void *theTaskDataPtr);

rpAccess CheckCurrentUserRealm(void)
{
void *httpServerDataPtr;
rpAccess realm;

httpServerDataPtr = RpHSGetServerData();
realm = RpGetCurrentRealm( httpServerDataPtr );

return realm;
}