ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/gtpwnamru.htm

341 lines
8.8 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<title>QlgGetpwnam_r()--Get User Information for User Name (using NLS-enabled
path name)</title>
<!-- Begin Header Records -->
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- Change History: -->
<!-- file cleaned -->
<!-- Created for V5R1-->
<!-- This file has undergone html cleanup June 2002 by JET -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<!-- End Header Records --><!--Java sync-link-->
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
</script>
<a name="Top_Of_Page"></a>
<h2>QlgGetpwnam_r()--Get User Information for User Name (using NLS-enabled path
name)</h2>
<div class="box" style="width: 80%;">
<br>
&nbsp;&nbsp;Syntax<br>
<pre>
#include &lt;sys/types.h&gt;
#include &lt;pwd.h&gt;
int QlgGetpwnam_r(const char <em>*name</em>,
struct qplg_passwd <em>*pwd</em>,
char <em>*buffer</em>,
size_t <em>bufsize</em>,
struct qplg_passwd <em>**result</em>);
</pre>
&nbsp;&nbsp;Service Program Name: QSYPAPI<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Yes<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong>QlgGetpwnam_r()</strong> function updates the <em>
qplg_passwd</em> structure pointed to by <em>pwd</em> and stores a pointer to
that structure in the location pointed to by <em>result</em>. The structure
contains an entry from the user database with a matching <em>name</em>.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong><em>name</em></strong></dt>
<dd>(Input) A pointer to a user profile name.<br>
</dd>
<dt><strong><em>pwd</em></strong></dt>
<dd>(Input) A pointer to a qplg_passwd structure.<br>
</dd>
<dt><strong><em>buffer</em></strong></dt>
<dd>(Input) A pointer to a buffer from which memory is allocated to hold
storage areas referenced by the structure <em>pwd</em>.<br>
</dd>
<dt><strong><em>bufsize</em></strong></dt>
<dd>(Input) The size of <em>buffer</em> in bytes.<br>
</dd>
<dt><strong><em>result</em></strong></dt>
<dd>(Input) A pointer to a location in which a pointer to the updated
qplg_passwd structure is stored. If an error occurs or if the requested entry
cannot be found, a NULL pointer is stored in this location.</dd>
</dl>
<p>The <samp>struct qplg_passwd</samp>, which is defined in the <strong>
pwd.h</strong> header file, has the following elements:</p>
<table border width="100%">
<tr>
<td align="left" valign="top" width="25%">char *</td>
<td align="left" valign="top" width="20%">pw_name</td>
<td align="left" valign="top" width="55%">User name</td>
</tr>
<tr>
<td align="left" valign="top">uid_t</td>
<td align="left" valign="top">pw_uid</td>
<td align="left" valign="top">User ID</td>
</tr>
<tr>
<td align="left" valign="top">uid_t</td>
<td align="left" valign="top">pw_gid</td>
<td align="left" valign="top">Group ID</td>
</tr>
<tr>
<td align="left" valign="top">Qlg_Path_Name_T*</td>
<td align="left" valign="top">pw_dir</td>
<td align="left" valign="top">Initial working directory</td>
</tr>
<tr>
<td align="left" valign="top">char *</td>
<td align="left" valign="top">pw_shell</td>
<td align="left" valign="top">Initial user program</td>
</tr>
</table>
<p>See <a href="gtpwnamr.htm">getpwnam_r()--Get User Information for User
Name</a> for more on the <em>pwd</em>, <em>result</em> and other
parameters.</p>
<br>
<h3>Authorities</h3>
<p>*READ authority is required to the user profile associated with the <em>
name</em>.</p>
<br>
<h3>Return Value</h3>
<dl>
<dt><em>0</em></dt>
<dd><strong>QlgGetpwnam_r</strong> was successful.<br>
<br>
</dd>
<dt><em>Any other value</em></dt>
<dd>Failure: The return value contains an error number indicating the
error.</dd>
</dl>
<br>
<h3>Error Conditions</h3>
<p>If <strong>QlgGetpwnam_r()</strong> is not successful, the return value
usually indicates one of the following errors. Under some conditions, the value
could indicate an error other than those listed here.</p>
<table cellpadding="5">
<!-- cols="25 75" -->
<tr>
<th align="left" valign="bottom">Error condition</th>
<th align="left" valign="bottom">Additional information</th>
</tr>
<tr>
<td align="left" valign="top">
<em>[<a href="unix14.htm#EAGAIN">EAGAIN</a>]</em></td>
<td align="left" valign="top">
<p>The user profile associated with the <em>name</em> is currently locked by
another process.</p>
</td>
</tr>
<tr>
<td align="left" valign="top">
<em>[<a href="unix14.htm#EC2">EC2</a>]</em></td>
<td align="left" valign="top">
<p>Detected pointer that is not valid.</p>
</td>
</tr>
<tr>
<td align="left" valign="top">
<em>[<a href="unix14.htm#EINVAL">EINVAL</a>]</em></td>
<td align="left" valign="top">
<p>Value is not valid. Check the job log for messages.</p>
</td>
</tr>
<tr>
<td align="left" valign="top">
<em>[<a href="unix14.htm#ENOENT">ENOENT</a>]</em></td>
<td align="left" valign="top">
<p>The user profile associated with the <em>name</em> was not found.</p>
</td>
</tr>
<tr>
<td align="left" valign="top">
<em>[<a href="unix14.htm#ENOMEM">ENOMEM</a>]</em></td>
<td align="left" valign="top">
<p>The user profile associated with the <em>UID</em> has exceeded its storage
limit or is unable to allocate memory.</p>
</td>
</tr>
<tr>
<td align="left" valign="top">
<em>[<a href="unix14.htm#EPERM">EPERM</a>]</em></td>
<td align="left" valign="top">
<p>The calling job does not have *READ authority to the user profile
associated with the <em>name</em>.</p>
</td>
</tr>
<tr>
<td align="left" valign="top">
<em>[<a href="unix14.htm#ERANGE">ERANGE</a>]</em></td>
<td align="left" valign="top">
<p>Insufficient storage was supplied through <em>buffer</em> and <em>
bufsize</em> to contain the data to be referenced by the resulting group
structure.</p>
</td>
</tr>
<tr>
<td align="left" valign="top">
<em>[<a href="unix14.htm#EUNKNOWN">EUNKNOWN</a>]</em></td>
<td align="left" valign="top">
<p>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.</p>
</td>
</tr>
</table>
<br>
<h3>Usage Notes</h3>
<p>The path name is returned in the default IFS UNICODE CCSID.</p>
<br>
<h3>Related Information</h3>
<ul>
<li>The &lt;<strong>pwd.h</strong>&gt; file (see <a href="unix13.htm">Header
Files for UNIX-Type APIs</a>)<br>
</li>
<li><a href="getpwnam.htm">getpwnam()</a>--Get User Information for User
Name<br>
</li>
<li><a href="gtpwnamr.htm">getpwnam_r()</a>--Get User Information for User
Name<br>
</li>
<li><a href="getpwnamu.htm">QlgGetpwnam()</a>--Get User Information for User
Name (using NLS-enabled path name)</li>
</ul>
<br>
<h3>Example</h3>
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
for information pertaining to code examples.</p>
<p>The following example gets the user database information for the user name
of MYUSER. The uid is 22. The gid is 1012. The initial working directory is
/home/MYUSER. The initial user program is *LIBL/QCMD.</p>
<pre>
#include &lt;sys/types.h&gt;
#include &lt;pwd.h&gt;
#include &lt;stdio.h&gt;
#include &lt;errno.h&gt;
main()
{
struct qplg_passwd pd;
qplg_passwd ** tempPwdPtr;
char pwdbuffer[200];
int pwdlinelen = sizeof(pwdbuffer);
if ((QlgGetpwnam_r("MYUSER",&amp;pd,pwdbuffer,pwdlinelen,tempPwdPtr))!=0 )
perror("QlgGetpwnam_r() error.");
else
{
printf("\nThe user name is: %s\n", pd-&gt;pw_name);
printf("The user id is: %u\n", pd-&gt;pw_uid);
printf("The group id is: %u\n", pd-&gt;pw_gid);
printf("The initial working directory length is: %d\n",
pd-&gt;pw_dir-&gt;Path_Length);
printf("The initial working directory CCSID is : %d\n",
pd-&gt;pw_dir-&gt;CCSID);
printf("The initial user program is: %s\n", pd-&gt;pw_shell);
}
}
</pre>
<p><strong>Output:</strong></p>
<pre>
The user name is: MYUSER
The user id is: 22
The group id is: 0
The intial working directory length is: 24
The intial working directory CCSID is : 13488
The initial user program is: *LIBL/QCMD
</pre>
<hr>
API introduced: V5R1
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
</tr>
</table>
</center>
</body>
</html>