⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 net.html

📁 perl教程
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>Win32API::Net - Perl interface to the Windows NT LanManager API account management functions.</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>

<body>

<script>writelinks('__top__',2);</script>
<h1><a>Win32API::Net - Perl interface to the Windows NT LanManager API account management functions.</a></h1>
<p><a name="__index__"></a></p>

<!-- INDEX BEGIN -->

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#synopsis">SYNOPSIS</a></li>
	<li><a href="#note_on_versions_prior_to_0_08">NOTE ON VERSIONS PRIOR TO 0.08</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<ul>

		<li><a href="#using_references">Using References</a></li>
	</ul>

	<li><a href="#data_structures">DATA STRUCTURES</a></li>
	<li><a href="#exports">EXPORTS</a></li>
	<li><a href="#net_user_functions">NET USER FUNCTIONS</a></li>
	<ul>

		<li><a href="#useradd_server__level__hash__error_">UserAdd(server, level, hash, error)</a></li>
		<li><a href="#userchangepassword_server__user__old__new_">UserChangePassword(server, user, old, new)</a></li>
		<li><a href="#userdel_server__user_">UserDel(server, user)</a></li>
		<li><a href="#userenum_server__array___filter__">UserEnum(server, array[, filter])</a></li>
		<li><a href="#usergetgroups_server__user__array_">UserGetGroups(server, user, array)</a></li>
		<li><a href="#usergetinfo_server__user__level__hash_">UserGetInfo(server, user, level, hash)</a></li>
		<li><a href="#usergetlocalgroups_server__user__array___flags__">UserGetLocalGroups(server, user, array[, flags])</a></li>
		<li><a href="#usermodalsget__"><code>UserModalsGet()</code></a></li>
		<li><a href="#usermodalsset__"><code>UserModalsSet()</code></a></li>
		<li><a href="#usersetgroups_server__user__array_">UserSetGroups(server, user, array)</a></li>
		<li><a href="#usersetinfo_server__user__level__hash__error_">UserSetInfo(server, user, level, hash, error)</a></li>
	</ul>

	<li><a href="#net_group_functions">NET GROUP FUNCTIONS</a></li>
	<ul>

		<li><a href="#groupadd_server__level__hash__error_">GroupAdd(server, level, hash, error)</a></li>
		<li><a href="#groupadduser_server__group__user_">GroupAddUser(server, group, user)</a></li>
		<li><a href="#groupdel_server__group_">GroupDel(server, group)</a></li>
		<li><a href="#groupdeluser_server__group__user_">GroupDelUser(server, group, user)</a></li>
		<li><a href="#groupenum_server__array_">GroupEnum(server, array)</a></li>
		<li><a href="#groupgetinfo_server__group__level__hash_">GroupGetInfo(server, group, level, hash)</a></li>
		<li><a href="#groupgetusers_server__group__array_">GroupGetUsers(server, group, array)</a></li>
		<li><a href="#groupsetinfo_server__group__level__hash__error_">GroupSetInfo(server, group, level, hash, error)</a></li>
		<li><a href="#groupsetusers_server__group__array_">GroupSetUsers(server, group, array)</a></li>
	</ul>

	<li><a href="#net_local_group_functions">NET LOCAL GROUP FUNCTIONS</a></li>
	<ul>

		<li><a href="#localgroupadd_server__level__hash__error_">LocalGroupAdd(server, level, hash, error)</a></li>
		<li><a href="#localgroupaddmember__"><code>LocalGroupAddMember()</code></a></li>
		<li><a href="#localgroupaddmembers_server__group__array_">LocalGroupAddMembers(server, group, array)</a></li>
		<li><a href="#localgroupdel_server__group_">LocalGroupDel(server, group)</a></li>
		<li><a href="#localgroupdelmember__"><code>LocalGroupDelMember()</code></a></li>
		<li><a href="#localgroupdelmembers_server__group__array_">LocalGroupDelMembers(server, group, array)</a></li>
		<li><a href="#localgroupenum_server__array_">LocalGroupEnum(server, array)</a></li>
		<li><a href="#localgroupgetinfo_server__group__level__hash_">LocalGroupGetInfo(server, group, level, hash)</a></li>
		<li><a href="#localgroupgetmembers_server__group__hash_">LocalGroupGetMembers(server, group, hash)</a></li>
		<li><a href="#localgroupsetinfo_server__level__hash__error_">LocalGroupSetInfo(server, level, hash, error)</a></li>
		<li><a href="#localgroupsetmembers__"><code>LocalGroupSetMembers()</code></a></li>
	</ul>

	<li><a href="#net_get_functions">NET GET FUNCTIONS</a></li>
	<ul>

		<li><a href="#getdcname_server__domain__domaincontroller_">GetDCName(server, domain, domain-controller)</a></li>
	</ul>

	<li><a href="#user_info_levels">USER INFO LEVELS</a></li>
	<li><a href="#user_info_fields">USER INFO FIELDS</a></li>
	<li><a href="#user_flags">USER FLAGS</a></li>
	<li><a href="#user_privilege_flags">USER PRIVILEGE FLAGS</a></li>
	<li><a href="#user_enum_filter">USER ENUM FILTER</a></li>
	<li><a href="#user_field_errors">USER FIELD ERRORS</a></li>
	<li><a href="#group_info_levels">GROUP INFO LEVELS</a></li>
	<li><a href="#group_info_fields">GROUP INFO FIELDS</a></li>
	<li><a href="#group_field_errors">GROUP FIELD ERRORS</a></li>
	<li><a href="#group_users_info_levels">GROUP USERS INFO LEVELS</a></li>
	<li><a href="#group_users_info_fields">GROUP USERS INFO FIELDS</a></li>
	<li><a href="#local_group_info_levels">LOCAL GROUP INFO LEVELS</a></li>
	<li><a href="#local_group_info_fields">LOCAL GROUP INFO FIELDS</a></li>
	<li><a href="#local_group_field_errors">LOCAL GROUP FIELD ERRORS</a></li>
	<li><a href="#examples">EXAMPLES</a></li>
	<li><a href="#author">AUTHOR</a></li>
	<li><a href="#see_also">SEE ALSO</a></li>
	<li><a href="#acknowedgements">ACKNOWEDGEMENTS</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Win32API::Net - Perl interface to the Windows NT LanManager API account management functions.</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<p>use Win32API::Net;</p>
<p>
</p>
<hr />
<h1><a name="note_on_versions_prior_to_0_08">NOTE ON VERSIONS PRIOR TO 0.08</a></h1>
<p>As of version 0.08 of this module, the behaviour relating to empty strings
in input hashes has changed. The old behaviour converted such strings to
the NULL pointer. The underlying API uses this value as an indication to
not change the value stored for a given field. This meant that you were not
able to clear (say) the logonScript field for a user using UserSetInfo().</p>
<p>The new behaviour is to leave the string as an empty C string which will
allow fields to be cleared.  To pass a NULL pointer to the underlying
API call (and thus, to leave the field as it was), you need to set the
corresponding field to <a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a>.</p>
<p>WARNING: <strong>THIS IS AN INCOMPATIBLE CHANGE</strong>.
<strong>EXISTING SCRIPTS THAT RELIED ON PRIOR BEHAVIOR MAY NEED TO BE MODIFIED</strong>.</p>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>Win32API::Net provides a more complete wrapper for the account management
parts of the NT LanManager API than do other similar packages. Most of what
you can achieve with the native C++ API is possible with this package - albeit
in a more Perl like manner by using references to pass information to and
from functions.</p>
<p>For an understanding of the environment in which these functions operate see
<a href="#data_structures">DATA STRUCTURES</a>.</p>
<p>The following groups of functions are available:</p>
<dl>
<dt><strong><a name="item_net_user_functions"><a href="#net_user_functions">NET USER FUNCTIONS</a></a></strong>

<dt><strong><a name="item_net_group_functions"><a href="#net_group_functions">NET GROUP FUNCTIONS</a></a></strong>

<dt><strong><a name="item_net_local_group_functions"><a href="#net_local_group_functions">NET LOCAL GROUP FUNCTIONS</a></a></strong>

<dt><strong><a name="item_net_get_functions"><a href="#net_get_functions">NET GET FUNCTIONS</a></a></strong>

</dl>
<p>All functions return 0 on failure and 1 on success. Use the
<code>Win32::GetLastError()</code> function to find out more information on why a
function failed. In addition, some functions that take a hash reference
to pass information in (e.g. <code>UserAdd()</code>) have a last argument that will
allow more detailed information on which key/value pair was not properly
specified.</p>
<p>
</p>
<h2><a name="using_references">Using References</a></h2>
<p>References to hashes and arrays are used throughout this package to pass
information into and out of functions.</p>
<dl>
<dt><strong><a name="item_using_hash_references">Using Hash References</a></strong>

<dd>
<p>Where a hash reference is required you can use anything that evaluates to a
hash reference. e.g.</p>
</dd>
<dd>
<pre>
        <span class="variable">$href</span> <span class="operator">=</span> <span class="operator">\</span><span class="variable">%someHash</span><span class="operator">;</span>
        <span class="variable">UserAdd</span><span class="operator">(</span><span class="variable">server</span><span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="variable">$hRef</span><span class="operator">);</span>
</pre>
</dd>
<dd>
<p>Or more directly:</p>
</dd>
<dd>
<pre>
        <span class="variable">UserAdd</span><span class="operator">(</span><span class="variable">server</span><span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="operator">\</span><span class="variable">%someHash</span><span class="operator">);</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_using_array_references">Using Array references</a></strong>

<dd>
<p>Array references are used in a similar manner to hash references. e.g.</p>
</dd>
<dd>
<pre>
        <span class="variable">$aref</span> <span class="operator">=</span> <span class="operator">\</span><span class="variable">@someArray</span><span class="operator">;</span>
        <span class="variable">UserEnum</span><span class="operator">(</span><span class="variable">server</span><span class="operator">,</span> <span class="variable">$aref</span><span class="operator">);</span>
</pre>
</dd>
<dd>
<p>Or more directly:</p>
</dd>
<dd>
<pre>
        <span class="variable">UserEnum</span><span class="operator">(</span><span class="variable">server</span><span class="operator">,</span> <span class="operator">\</span><span class="variable">@someArray</span><span class="operator">);</span>
</pre>
</dd>
</li>
</dl>
<p>Please note: Any <code>*Get*()</code> or <code>*Enum()</code> operation will first clear the
contents of the input hash or array being referenced.</p>
<p>See <em>EXAMPLES</em> and the test.pl script for examples of usage.</p>
<p>
</p>
<hr />
<h1><a name="data_structures">DATA STRUCTURES</a></h1>
<p>Most the the functions in the underlying API allow the programmer to pass
specify at runtime the amount of information that is supplied to the
function. For example, the <code>NetUserGetInfo()</code> call allows the programmer to
specify levels of 0, 1, 2, 3 (and others). Having specified this level, the
function returns a structure that will contain different fields. For a
level <code>0</code>, the function returns a structure that has only one field. For a
supplied level of 1, the function returns a structure with <code>8</code> fields. The
programmer needs to know in advance what fields should be provided or will
be returned for a given level. This mechanism works very will since it
effectively overloads functions without having to use different function
prototypes. Perl provides better higher level data structures in the form
of arrays and hashes. This package uses hashes as the means to pass these
variable size structure into and out of functions.</p>
<p>For any function that takes a reference to a hash as input, the programmer
is expected to provide appropriate keys and corresponding values as well as
the level parameter. The called function will then takes the values out of
the supplied hash and build the approprite structure to pass to the
underlying API function.</p>
<p>For any function that takes a reference to a hash to recieve output, the
function will first clear any keys an corresponding values in the supplied
hash. It will call the underlying API call and will then return in the hash
any keys and values that are applicable at the requested level.</p>
<p>Example:</p>
<p>The <code>UserGetInfo()</code> can takes a number of levels. If called with level <code>0</code>
the supplied hash will, on return from the function, contain a single key
and value - namely <strong>name</strong>/<strong>requested-users-name</strong>. If called with a level
of <code>1</code> the supplied hash will, on return from the function, contain 8 keys
and values. The returned keys are <code>name, password</code>, <code>passwordAge</code>,
<code>priv</code>, <code>homeDir</code>, <code>comment</code>, <a href="../../lib/Pod/perlfunc.html#item_flags"><code>flags</code></a>, <code>scriptPath</code>. See
<a href="#user_info_fields">USER INFO FIELDS</a> for more information on what these represent.</p>
<p>
</p>
<hr />
<h1><a name="exports">EXPORTS</a></h1>
<p>By default, Win32API::Net exports no symbols into the callers namespace.
The following tags can be used to selectively import symbols into the
main namespace.</p>
<dl>
<dt><strong><a name="item__3auser"><code>:User</code></a></strong>

<dd>
<p>Exports all symbols needed for the <code>User*()</code> functions.
See <a href="#net_user_functions">NET USER FUNCTIONS</a>.</p>
</dd>
</li>
<dt><strong><a name="item__3aget"><code>:Get</code></a></strong>

<dd>
<p>Exports all symbols needed for the <code>Get*()</code> functions.
See <a href="#net_get_functions">NET GET FUNCTIONS</a>.</p>
</dd>
</li>
<dt><strong><a name="item__3agroup"><code>:Group</code></a></strong>

<dd>
<p>Exports all symbols needed for the <code>Group*()</code> functions.
See <a href="#net_group_functions">NET GROUP FUNCTIONS</a>.</p>
</dd>
</li>
<dt><strong><a name="item__3alocalgroup"><code>:LocalGroup</code></a></strong>

<dd>
<p>Exports all symbols needed for the <code>LocalGroup*()</code> functions.
See <a href="#net_local_group_functions">NET LOCAL GROUP FUNCTIONS</a>.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="net_user_functions">NET USER FUNCTIONS</a></h1>
<p>The <code>User*()</code> functions operate on NT user accounts.</p>
<p>Administrator or Account Operator group membership is required to
successfully execute most of these functions on a remote server or on a
computer that has local security enabled. Administrator privileges are
required to add an Administrator Privilege account.  There are some
exceptions to this whereby a user can change some of their own settings
where these don't conflict with 'administrative information' (e.g. full
name).</p>
<p>The <code>server</code> field can be the empty string, in which case the function
defaults to running on the local computer. If you leave this field blank
then you should ensure that you are running the function on a PDC or BDC
for your current domain. Use the support function <code>GetDCName()</code> to find out
what the domain controller is, should you not be running this on the PDC.</p>
<p>All functions in this section are 'DOMAIN functions'. This means that,
for example, the <code>UserGetLocalGroups()</code> function actually lists the
domain's local groups of which the named user is a member.</p>
<p>The following functions are available.</p>
<p>
</p>
<h2><a name="useradd_server__level__hash__error_">UserAdd(server, level, hash, error)</a></h2>
<p>Add a new user account. The user name is taken from the <code>name</code>-key's
value in the supplied hash.</p>
<dl>
<dt><strong><a name="item_server__2d_scalar_string"><code>server</code> - Scalar String</a></strong>

<dd>
<p>The server on which to add the account.</p>
</dd>
</li>
<dt><strong><a name="item_level__2d_scalar_int"><code>level</code> - Scalar Int</a></strong>

<dd>
<p>Level of information provided in hash. This can be either 1, 2 or 3.
See <a href="#user_info_levels">USER INFO LEVELS</a>.</p>
</dd>
</li>
<dt><strong><a name="item_hash__2d_hash_reference"><code>hash</code> - Hash Reference</a></strong>

<dd>
<p>The information to use to add this account. This should have all the
appropriate keys and values required for <code>level</code>.</p>
</dd>
</li>
<dt><strong><a name="item_error__2d_scalar_int"><code>error</code> - Scalar Int</a></strong>

<dd>
<p>Provides information on which field in the hash was not properly specified.
See <a href="#user_field_errors">USER FIELD ERRORS</a> for more information about what values this can
take.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="userchangepassword_server__user__old__new_">UserChangePassword(server, user, old, new)</a></h2>
<p>Changes the password for <code>user</code>. If the policy of the machine/domain
only allows password changes if the <code>user</code> is logged on then the <code>user</code>
must be logged on to execute this function. With Administrator or Account
Operator privilege you can use this function to change anyone's password,
so long as you know the old password.</p>
<dl>
<dt><strong><code>server</code> - Scalar String</strong>

<dd>
<p>The <code>server</code> on which to change the password.</p>
</dd>
</li>
<dt><strong><a name="item_user__2d_scalar_string"><code>user</code> - Scalar String</a></strong>

<dd>
<p>The name of the <code>user</code> whose password is being changed.</p>
</dd>
</li>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -