Description |
The tnet_get_user_id retrieves the user identification
number, when the telnet console is protected with user
authentication. It can be used to disable restricted commands for
unprivileged users. This function is normally called from the
tnet_process_cmd or tnet_cbfunc functions.
The tnet_get_user_id is a system function that is in the
RL-TCPnet library. The prototype is defined in net_config.h.
note
-
This function returns a value of 0 for system administrator
account.
|
Example |
U16 tnet_process_cmd (U8 *cmd, U8 *buf, U16 buflen, U32 *pvar) {
REMOTEM rm;
U16 len = 0;
U8 uid;
..
uid = tnet_get_user_id ();
if ((tnet_ccmp (cmd, "RINFO") == __TRUE) && (uid == 0)) {
/* Display Remote Machine IP and MAC address. */
/* Restricted to the 'admin' account only. */
tnet_get_info (&rm);
len = sprintf ((char *)buf,"\r\n Remote IP : %d.%d.%d.%d",
rm.IpAdr[0],rm.IpAdr[1],rm.IpAdr[2],rm.IpAdr[3]);
len += sprintf ((char *)(buf+len),
"\r\n Remote MAC: %02X-%02X-%02X-%02X-%02X-%02X",
rm.HwAdr[0],rm.HwAdr[1],rm.HwAdr[2],
rm.HwAdr[3],rm.HwAdr[4],rm.HwAdr[5]);
return (len);
}
..
}
|