QlgGetpwuid()--Get User Information for User ID (using NLS-enabled path name)


  Syntax
 #include <pwd.h>

 struct qplg_passwd *QlgGetpwuid(uid_t uid);   
  Service Program Name: QSYPAPI

  Default Public Authority: *USE

  Threadsafe: No

The QlgGetpwuid() function returns a pointer to an object of type struct qplg_passwd containing an entry from the user database with a matching user ID (UID).


Parameters

UID
(Input) User ID.

The struct qplg_passwd, which is defined in the pwd.h header file, has the following elements:

char * pw_name User name
uid_t pw_uid User ID
uid_t pw_gid Group ID
Qlg_Path_Name_T* pw_dir Initial working directory
char * pw_shell Initial user program

See getpwuid()--Get User Information for User ID for more on the parameter.


Authorities

*READ authority is required to the user profile associated with the UID.

Note: Adopted authority is not used.


Return Value

value
QlgGetpwuid() was successful. The return value points to static data that is overwritten on each call to this function. This static storage area is also used by the QlgGetpwnam() function.

NULL pointer
QlgGetpwuid() was not successful. The errno global variable is set to indicate the error.

Error Conditions

If QlgGetpwuid() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.

Error condition Additional information
[EAGAIN]

The user profile associated with the uid is currently locked by another process.

[EC2]

Detected pointer that is not valid.

[EINVAL]

Value is not valid. Check the job log for messages.

[ENOENT]

The user profile associated with UID was not found.

[ENOMEM]

The user profile associated with the UID has exceeded its storage limit or is unable to allocate memory.

[ENOSPC]

Machine storage limit exceeded.

[EPERM]

The calling job does not have *READ authority to the user profile associated with the UID.

[EUNKNOWN]

Unknown system state. Check the job log for a CPF9872 message. If there is no message, verify that the home directory field in the user profile can be displayed.


Usage Notes

Th path name is returned in the default IFS UNICODE CCSID


Related Information


Example

See Code disclaimer information for information pertaining to code examples.

The following example gets the user database information for the uid of 22. The user name is MYUSER. The gid is 1012. The initial working directory is /home/MYUSER. The initial user program is *LIBL/QCMD.

#include <pwd.h>

main()
{
  struct qplg_passwd *pd;

  if (NULL == (pd = QlgGetpwuid(22)))
     perror("QlgGetpwuid() error.");
  else
  {
     printf("The user name is: %s\n", pd->pw_name);
     printf("The user id   is: %u\n", pd->pw_uid);
     printf("The group id  is: %u\n", pd->pw_gid);
     printf("The initial working directory length is: %d\n",
             pd->pw_dir->Path_Length);
     printf("The initial working directory CCSID is : %d\n",
             pd->pw_dir->CCSID);
     printf("The initial user program is: %s\n", pd->pw_shell);
  }

}

Output:

  The user name is: MYUSER
  The user id   is: 22
  The group id  is: 1012
  The intial working directory length is: 24
  The intial working directory CCSID is : 13488
  The initial user program is: *LIBL/QCMD


API introduced: V5R1
Top | UNIX-Type APIs | APIs by category