1601 lines
52 KiB
HTML
1601 lines
52 KiB
HTML
<html>
|
||
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||
<title>Active Directory Service Interfaces - WinNT</title>
|
||
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
|
||
</head>
|
||
|
||
<body topmargin="0" leftmargin="0">
|
||
|
||
<table border="0" height="86" cellpadding="0" cellspacing="0">
|
||
<tr>
|
||
<td width="77%" valign="top" height="58"><map name="FPMap2">
|
||
<area href="http://www.microsoft.com/windows2000/library/howitworks/activedirectory/adsilinks.asp" shape="rect" coords="4, 6, 248, 57"></map><img src="banner.gif"
|
||
border="0" alt="http://www.microsoft.com/windows2000/library/howitworks/activedirectory/adsilinks.asp" width="250" height="60" usemap="#FPMap2"></td>
|
||
<td width="3%" height="58"></td>
|
||
<td width="21%" height="58" valign="bottom"><p align="right"><map name="FPMap3">
|
||
<area href="http://www.microsoft.com" shape="rect" coords="7, 6, 108, 39"></map><img src="mslogo.gif"
|
||
border="0" alt="http://www.microsoft.com" width="112" height="40" usemap="#FPMap3"></td>
|
||
</tr>
|
||
<tr>
|
||
<td valign="top" align="left" height="28"><map name="FPMap0">
|
||
<area href="rtk.htm" shape="rect" coords="420, 1, 515, 18" ALT="rtk.htm">
|
||
<area href="interopt.htm" shape="rect" coords="350, 1, 415, 19" ALT="interopt.htm">
|
||
<area href="ad.htm" shape="rect" coords="233, 1, 345, 19" ALT="ad.htm">
|
||
<area href="winnt.htm" shape="rect" coords="165, 1, 223, 19" ALT="winnt.htm">
|
||
<area href="dev.htm" shape="rect" coords="67, 1, 165, 19" ALT="dev.htm">
|
||
<area href="../default.htm" shape="rect" coords="13, 1, 65, 20" ALT = "../default.htm"></map>
|
||
<img rectangle="(233,1) (345, 19) ad.htm" rectangle="(165,1) (223, 19) winnt.htm" rectangle="(67,1) (165, 19) dev.htm" rectangle="(13,1) (65, 20) ../default.htm" src="router.gif" alt="router.gif (3874 bytes)" border="0" usemap="#FPMap0" width="536" height="26"></td>
|
||
<td width="3%" height="28"></td>
|
||
<td width="21%" height="28"></td>
|
||
</tr>
|
||
</table>
|
||
|
||
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="38">
|
||
|
||
<tr>
|
||
<td width="3%" height="19"></td>
|
||
<td width="97%" height="19"></td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td width="3%" height="74"></td>
|
||
<td width="97%" height="74"><img src="http://adsi/sdk/winnt.gif" alt="winnt.gif (3693 bytes)" width="201"
|
||
height="80"></td>
|
||
</tr>
|
||
|
||
<tr>
|
||
|
||
<td width="3%" height="21"></td>
|
||
|
||
<td width="97%" height="21">
|
||
|
||
|
||
<p>
|
||
|
||
<font face="Verdana"><small>The ADSI WinNT provider allows you to
|
||
communicate to a Windows NT<4E> 4.0 directory. Since Windows 2000 maintains backward compatibility, you
|
||
can also communicate with Windows<small><EFBFBD></small> 2000 machines using WinNT. However, we recommend
|
||
that you use the LDAP provider to communicate with Windows 2000 domain controllers. For the Windows 2000
|
||
standalone server and Professional Edition, you must use the WinNT provider to access the
|
||
directory.</small></font>
|
||
|
||
</p>
|
||
|
||
<p><font face="Verdana"><small>WinNT supports local and remote
|
||
accounts, services, computers, security management and other functionalities. With ADSI extensions,
|
||
you'll be able to extend the functionality. For more information on ADSI extensions, click
|
||
<a href="extension.htm">here</a>.</small></font></p>
|
||
|
||
<p><strong><font face="Verdana" color="#0080C0"><small>Requirements</small></font></strong></p>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana"><small>Install ADSI. To download the runtime, visit
|
||
<a href="http://www.microsoft.com/adsi">http://www.microsoft.com/adsi</a> on
|
||
Windows NT 4.0 or Windows 95. <b>Note:</b> If you have Windows 2000 machine,
|
||
you don't need to install ADSI. ADSI is a built-in component for Windows 2000.</small><br>
|
||
</font></li>
|
||
|
||
<li><font face="Verdana"><small>You must have a Windows NT 4.0 or Windows 2000 or higher to connect
|
||
to. The client and server may be on the same machine.</small></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><small><font face="Verdana">Set up your <a href="dev.htm">development environment</a>.</font></small></li>
|
||
|
||
</ul>
|
||
|
||
<p> </p>
|
||
|
||
<p><font face="Verdana" color="#0080C0"><strong><small>How do I...</small>
|
||
</strong></font></p>
|
||
|
||
<p><a name="top_bind"></a><font face="Verdana" color="#0080C0"><strong><small>Bind</small></strong></font></p>
|
||
|
||
<ul>
|
||
|
||
<li><strong><font face="Verdana" color="#0080C0"><small><a href="#bind_domain">Binding to
|
||
a Windows NT 4.0 domain directory</a></small></font></strong>
|
||
|
||
<br>
|
||
|
||
<font face="Verdana" color="#000000"><small>A Windows machine may participate in a domain.
|
||
You must know the domain name to which you want to bind.</small></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#bind_local">Binding to a
|
||
Windows NT 4.0 local directory of a machine</a></small></strong></font>
|
||
|
||
<br>
|
||
|
||
<font face="Verdana" color="#000000"><small>Each Windows NT workstation and standalone server
|
||
has its own directory. You use the Mini User Manager (or Windows 2000 Local User Manager) tool
|
||
to manage it. You must know the machine name to which you want to bind.</small></font></li>
|
||
|
||
</ul>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="top_user"></a><strong><font face="Verdana" color="#0080C0"><small>Manage
|
||
Users</small></font></strong></p>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#user_create">Creating a
|
||
User</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#user_fullname">Changing
|
||
the User's Full Name and Description</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><strong><font face="Verdana" color="#0080C0"><small><a href="#user_pwd_change">Changing
|
||
the User's Password</a></small></font></strong></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><strong><font face="Verdana" color="#0080C0"><small><a href="#user_pwd_set">Setting
|
||
the User's Password</a></small></font></strong></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><strong><font face="Verdana" color="#0080C0"><small><a href="#user_pwd_expire">Setting
|
||
the User's Password Expiration Date</a></small></font></strong></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#usr_pwd_nextLogon">Making
|
||
the User Change the Password at Next Logon</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#user_pwd_cant_change">Preventing
|
||
the User from changing the Password</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#user_pwd_never">Setting
|
||
the User's Password so that it Never Expires</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#user_acct_disabled">Disabling
|
||
the User's Account</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#usr_acct_expire">Setting
|
||
the Expiration Date on the User's Account</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><strong><font face="Verdana" color="#0080C0"><small><a href="#user_acct_unlock">Unlocking
|
||
the User's Account</a></small></font></strong></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#user_home_dir">Setting
|
||
the User's Home Directory and Home Drive Directory</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#user_login_script">Setting
|
||
the User's Login Script</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#usr_primary_group">Getting
|
||
the User's Primary Group</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#user_sid">Getting the
|
||
User's SID (Security ID)</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><strong><small><font face="Verdana" color="#0080C0"><a href="#user_group">Getting
|
||
groups a user belongs to</a></font></small></strong></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><strong><font face="Verdana" color="#0080C0"><small><a href="#usr_delete">Deleting a
|
||
User</a></small></font></strong></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><strong><font face="Verdana" color="#0080C0"><small><a href="#user_rename">Renaming a
|
||
User</a></small></font></strong></li>
|
||
|
||
</ul>
|
||
|
||
<p><font face="Verdana"><small>You can the source code for these tasks in the
|
||
<a href="../samples/WinNT/User">\\samples\WinNT\User</a> directory.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="top_group"></a><strong><font face="Verdana" color="#0080C0"><small>Manage
|
||
a Group</small></font></strong>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#group_create">Creating a
|
||
Group</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><strong><font face="Verdana" color="#0080C0"><small><a href="#group_add_user">Adding a
|
||
User to a Group</a></small></font></strong></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#group_add">Adding a
|
||
Group to a Group</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#group_enumerate">Enumerating
|
||
Group in a Domain or Computer</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#group_member">Enumerating
|
||
Group Membership</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#group_remove">Removing
|
||
a Member from the Group</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#group_ismember">Finding
|
||
Out if a User or Group is a Member of a Group</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<p><font face="Verdana"><small>You can the source code for these tasks in the
|
||
<a href="../samples/WinNT/PrintQueue">\\samples\WinNT\Group</a> directory.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="top_computer"></a><font face="Verdana" color="#0080C0"><strong><small>Manage
|
||
a Computer</small></strong></font>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#computer">Connecting to a
|
||
Computer</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#service_enumerate">Enumerating
|
||
Services in a Computer</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#service_display">Displaying
|
||
a Service's Properties</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#service_operations">Stopping
|
||
and Starting a Service</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#fileshare_enumerate">Enumerating
|
||
File Shares in a Computer</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#fileshare_create">Creating a
|
||
File Share in a Computer</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#fileshare_delete">Deleting a
|
||
File Share</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#fileshare_security">Setting
|
||
File Share Security</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#session">Enumerating
|
||
Sessions in a Computer</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#resource">Enumerating
|
||
Resources in a Computer</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#resource">Creating
|
||
a Machine Account</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<p><font face="Verdana"><small>You can the source code for these tasks in the
|
||
<a href="../samples/WinNT/Computer">\\samples\WinNT\Computer</a> directory.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="top_file"></a><font face="Verdana" color="#0080C0"><strong><small>Manage
|
||
Printers</small></strong></font><ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#print_enumerate">Enumerating
|
||
Print Queues in a Computer</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#0080C0"><strong><small><a href="#print_job">Listing Print Jobs
|
||
in a Queue</a></small></strong></font></li>
|
||
|
||
</ul>
|
||
|
||
<p><font face="Verdana"><small>You can the source code for these tasks in the
|
||
<a href="../samples/WinNT/PrintQueue">
|
||
\\samples\WinNT\PrintQueue</a>
|
||
directory.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="top_file"></a><strong><font face="Verdana" color="#0080C0"><small>Manage
|
||
Files</small></font></strong>
|
||
|
||
<ul>
|
||
|
||
<li><strong><font face="Verdana" color="#0080C0"><small><a href="#file">Setting and
|
||
Getting File Security</a></small></font></strong></li>
|
||
|
||
</ul>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="bind_domain"></a><font face="Verdana" color="#0080C0"><strong><small>Binding
|
||
to a Windows NT 4.0 Domain Directory</small></strong></font></p>
|
||
|
||
<p><font face="Verdana" color="#000000"><small>You must supply the Windows NT 4.0 domain name.
|
||
ADSI will transparently connect to one of the domain controllers.</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>
|
||
'--- Binding to a domain
|
||
<br>
|
||
<br>
|
||
domainName = "INDEPENDENCE"<br>
|
||
userName = "Administrator"<br>
|
||
password = "password"<br>
|
||
<br>
|
||
<br>
|
||
'--- Binding to a domain as a currently logged on user<br>
|
||
<br>
|
||
Set dom = GetObject("WinNT://" & domainName)<br>
|
||
<br>
|
||
<br>
|
||
'--- Enumerating an object in a domain<br>
|
||
<br>
|
||
For Each obj In dom<br>
|
||
Debug.Print obj.Name & " (" & obj.Class & ")"<br>
|
||
Next<br>
|
||
<br>
|
||
<br>
|
||
'--- Binding to a domain with alternate credentials<br>
|
||
<br>
|
||
Set dso = GetObject("WinNT:")<br>
|
||
Set dom = dso.OpenDSObject("WinNT://" & domainName, userName, password,
|
||
ADS_SECURE_AUTHENTICATION)<br>
|
||
<br>
|
||
<br>
|
||
'--- Enumerating the object in a domain<br>
|
||
<br>
|
||
For Each obj In dom<br>
|
||
Debug.Print obj.Name & " (" & obj.Class & ")"<br>
|
||
Next</small></font></p>
|
||
|
||
<!--
|
||
<p><font face="Verdana"><small>For VBScript click here.</small><br>
|
||
<small>For VC++ Source Code, click here.</small></font></p>
|
||
-->
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_bind">top</a>.</small></font></p>
|
||
<p> </p>
|
||
<p><a name="bind_local"></a><font face="Verdana" color="#0080C0"><strong><small>Binding to
|
||
a Windows NT 4.0 Local Directory on a Machine</small></strong></font><br>
|
||
|
||
<br>
|
||
<br>
|
||
|
||
<font face="Verdana"><small>'--- Binding to a computer<br>
|
||
|
||
<br>
|
||
|
||
computerName = "ADSI"<br>
|
||
userName = "Administrator"<br>
|
||
password = "password"<br>
|
||
|
||
<br>
|
||
<br>
|
||
|
||
'--- Binding to a computer as a currently logged on user<br>
|
||
|
||
<br>
|
||
|
||
Set com = GetObject("WinNT://" & computerName & ",computer")<br>
|
||
'- Enumerate object in a computer<br>
|
||
For Each obj In com<br>
|
||
Debug.Print obj.Name & " (" & obj.Class & ")"<br>
|
||
Next<br>
|
||
|
||
<br>
|
||
<br>
|
||
|
||
'--- Binding to a computer with alternate credentials<br>
|
||
|
||
<br>
|
||
|
||
Set dso = GetObject("WinNT:")<br>
|
||
Set com = dso.OpenDSObject("WinNT://" & computerName &
|
||
",computer", userName, password, ADS_SECURE_AUTHENTICATION)<br>
|
||
|
||
<br>
|
||
<br>
|
||
|
||
'--- Enumerating an object in a computer<br>
|
||
|
||
<br>
|
||
|
||
For Each obj In com<br>
|
||
Debug.Print obj.Name<br>
|
||
Next</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_bind">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="user_create"></a><font face="Verdana" color="#0080C0"><strong><small>Creating
|
||
a User</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>domainName = "INDEPENDENCE"<br>
|
||
|
||
<br>
|
||
<br>
|
||
|
||
'--- Binding to a domain as currently logged on user<br>
|
||
|
||
<br>
|
||
|
||
Set dom = GetObject("WinNT://" & domainName)<br>
|
||
|
||
<br>
|
||
<br>
|
||
|
||
'--- Creating a user<br>
|
||
|
||
<br>
|
||
|
||
Set usr = dom.Create("user", "JSmith")<br>
|
||
usr.SetInfo</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="user_fullname"></a><font face="Verdana" color="#0080C0"><strong><small>Changing
|
||
the User's Full Name and Description</small></strong></font></p>
|
||
|
||
<p><small><font face="Verdana">Set usr =
|
||
GetObject("WinNT://INDEPENDENCE/jsmith,user")<br>
|
||
usr.FullName = "John Smith"<br>
|
||
usr.Description = "DSys WOSD Program Manager"<br>
|
||
usr.SetInfo
|
||
</font></small></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="user_pwd_change"></a><font face="Verdana" color="#0080C0"><strong><small>Changing
|
||
the User's Password</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>A user may change his/her own password, but not others.
|
||
Administrators have privileges to change any user's password. <strong>ChangePassword</strong>
|
||
requires an old password and the user must already exist in the directory, while <strong>SetPassword</strong>
|
||
does not. Both functions do not require <b> SetInfo</b> to commit the changes.</small></font></p>
|
||
|
||
|
||
<small><font face="Verdana">'--- Changing the password</font></small>
|
||
|
||
<p><font face="Verdana"><small>Set usr = GetObject("WinNT://INDEPENDENCE/jsmith,user")<br>
|
||
usr.ChangePassword "secret", "password"</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p><a name="user_pwd_set"></a><font face="Verdana" color="#0080C0"><strong><small>Setting
|
||
the User's Password</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>Administrators may reset the user password.</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>'--- Setting the password</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Set usr = GetObject("WinNT://INDEPENDENCE/jsmith,user")</small>
|
||
|
||
<br>
|
||
|
||
<small>usr.SetPassword "secret"</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="user_pwd_expire"></a><font face="Verdana" color="#0080C0"><strong><small>Setting
|
||
the User's Password Expiration Date</small></strong></font>
|
||
|
||
<p><font face="Verdana" color="#000000"><small>The password expiration date is a
|
||
calculated field. The value is computed as follows:</small></font>
|
||
|
||
<ul>
|
||
|
||
<li><font face="Verdana" color="#000000"><small>If the user's "Password Never
|
||
Expires" (UF_DONT_EXPIRE_PASSWD) f lag is set, then there's no need to
|
||
compute an expiration date. The user password is valid.</small></font></li>
|
||
|
||
<li><font face="Verdana" color="#000000"><small>If the user's flag is not set, then it
|
||
computes the difference between when the password was last set and current time.</small></font></li>
|
||
|
||
<li><font face="Verdana" color="#000000"><small>If the difference is greater or equal to
|
||
the <b>MaxPasswordAge</b> found in the domain object, then the user's password is expired.</small></font></li>
|
||
|
||
<li><font face="Verdana" color="#000000"><small>If the difference is less than
|
||
<b>MaxPasswordAge</b>, then the user's password expiration date = user's password last set +
|
||
<b>MaxPasswordAge</b>.</small></font></li>
|
||
|
||
</ul>
|
||
|
||
<p><font face="Verdana" color="#000000"><small>To get the user's password expiration date:</small></font></p>
|
||
|
||
<p><font face="Verdana" color="#000000"><small>To set user's password expiration date,
|
||
you set <b>MaxPasswordAge</b> in the domain object. Note that this will affect all users since
|
||
the password expiration date is a calculated field from the domain object.</small></font></p>
|
||
|
||
<p><small><font face="Verdana">
|
||
|
||
expInDay = 60&<br>
|
||
|
||
expInSec = expInDay * (3600& * 24&)<br>
|
||
|
||
Set dom = GetObject("WinNT://INDEPENDENCE")<br>
|
||
|
||
dom.Put "MaxPasswordAge", CLng(expInSec)<br>
|
||
|
||
dom.SetInfo</font></small></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="usr_pwd_nextLogon"></a><font face="Verdana" color="#0080C0"><strong><small>Making
|
||
a User Change the Password at Next Logon</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>Set usr = GetObject("WinNT://INDEPENDENCE/jsmith,user")<br>
|
||
|
||
usr.Put "PasswordExpired", CLng(1)<br>
|
||
usr.SetInfo
|
||
|
||
<br>
|
||
<br>
|
||
|
||
'--- Clear this flag so that the user does <u>not</u> have to change the
|
||
password at next logon.<br>
|
||
|
||
<br>
|
||
|
||
usr.Put "PasswordExpired", CLng(0)<br>
|
||
|
||
usr.SetInfo</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="user_pwd_cant_change"></a><font face="Verdana" color="#0080C0"><strong><small>Preventing
|
||
the User from Changing the Password</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>Set usr = GetObject("WinNT://INDEPENDENCE/jsmith,user")<br>
|
||
|
||
usr.Put "userFlags", usr.Get("UserFlags") Or ADS_UF_PASSWD_CANT_CHANGE<br>
|
||
|
||
usr.SetInfo
|
||
|
||
<br>
|
||
<br>
|
||
|
||
'--- To clear this flag, use Xor and allow the user to change his/her password.<br>
|
||
<br>
|
||
|
||
usr.Put "userFlags", usr.Get("UserFlags") Xor ADS_UF_PASSWD_CANT_CHANGE<br>
|
||
usr.SetInfo</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="user_pwd_never"></a><font face="Verdana" color="#0080C0"><strong><small>Preventing
|
||
the User's Password from Expiring</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>Set usr = GetObject("WinNT://INDEPENDENCE/jsmith,user")<br>
|
||
|
||
usr.Put "userFlags", usr.Get("UserFlags") Or UF_DONT_EXPIRE_PASSWD<br>
|
||
|
||
usr.SetInfo
|
||
|
||
<br>
|
||
<br>
|
||
|
||
'--- To clear this flag, use XOr.<br>
|
||
|
||
<br>
|
||
|
||
usr.Put "userFlags", usr.Get("UserFlags") Xor UF_DONT_EXPIRE_PASSWD<br>
|
||
usr.SetInfo</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="user_acct_disabled"></a><font face="Verdana" color="#0080C0"><strong><small>Disabling
|
||
the User's Account</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>Set usr = GetObject("WinNT://INDEPENDENCE/jsmith,user")</small>
|
||
|
||
<br>
|
||
|
||
<small>usr.AccountDisabled = True
|
||
'Disabled the account</small></font></p>
|
||
|
||
<p><font face="Verdana">
|
||
|
||
<small><br>
|
||
|
||
usr.SetInfo
|
||
|
||
<br>
|
||
|
||
usr.AccountDisabled = False
|
||
'Enabled the account<br>
|
||
|
||
usr.SetInfo</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="usr_acct_expire"></a><font face="Verdana" color="#0080C0"><strong><small>Setting
|
||
the User's Account Expiration Date</small></strong></font></p>
|
||
|
||
<p><small><font face="Verdana">Set usr = GetObject("WinNT://INDEPENDENCE/jsmith,user")</font></small></p>
|
||
|
||
<p><font face="Verdana"><small>'--Set a user account expiration 90 days from now.</small></font></p>
|
||
|
||
<p><font face="Verdana">
|
||
|
||
<small>usr.AccountExpirationDate = Now() + 90<br>
|
||
|
||
usr.SetInfo
|
||
|
||
<br>
|
||
|
||
<br>
|
||
|
||
'--- To set the account expiration to <u>NEVER</u> (default).<br>
|
||
|
||
<br>
|
||
|
||
usr.AccountExpirationDate = "01/01/1970"<br>
|
||
|
||
usr.SetInfo</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="user_acct_unlock"></a><font face="Verdana" color="#0080C0"><strong><small>Unlocking
|
||
the User's Account</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small> You can read the value of account lockout,
|
||
and you can set the lockout to FALSE (not locked), but you can't
|
||
lock the user's account. Only the system
|
||
can set the account lockout to TRUE. <br>
|
||
|
||
<br>
|
||
|
||
'--- Unlocking the user's account</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Set usr = GetObject("WinNT://INDEPENDENCE/jsmith,user)</small><br>
|
||
<small>usr.IsAccountLocked = False<br>
|
||
|
||
usr.SetInfo</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="user_home_dir"></a><font face="Verdana" color="#0080C0"><strong><small>Setting
|
||
the User's Home Directory and Home Drive Directory</small></strong></font></p>
|
||
|
||
<p><a name="usr_primary_group"></a><small><font face="Verdana">Set usr = GetObject("WinNT://INDEPENDENCE/jsmith,user")
|
||
|
||
<br>
|
||
|
||
usr.HomeDirectory = "UserHomeDirHere"<br>
|
||
usr.HomeDirDrive = "HomeDirDriveHere"<br>
|
||
usr.SetInfo</font></small></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="user_login_script"></a><font face="Verdana" color="#0080C0"><strong><small>Setting
|
||
the User's Login Script</small></strong></font></p>
|
||
|
||
<p><small><font face="Verdana">Set usr = GetObject("WinNT://INDEPENDENCE/jsmith,user")
|
||
|
||
<br>
|
||
|
||
usr.LoginScript = "LoginScriptHere"
|
||
|
||
<br>
|
||
|
||
usr.SetInfo</font></small></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="user_primary_group"></a><font face="Verdana" color="#0080C0"><strong><small>Getting
|
||
the User's Primary Group</small></strong></font></p>
|
||
|
||
<p><small><font face="Verdana">Set usr = GetObject("WinNT://INDEPENDENCE/jsmith,user")
|
||
|
||
<br>
|
||
|
||
grpPrimaryID = usr.Get("PrimaryGroupID")</font></small></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="user_sid"></a><font face="Verdana" color="#0080C0"><strong><small>Getting the
|
||
User's SID (Security ID)</small></strong></font></p>
|
||
|
||
<p><small><font face="Verdana">Set usr = GetObject("WinNT://INDEPENDENCE/jsmith,user")
|
||
|
||
<br>
|
||
|
||
sid = usr.Get("objectSID")<br>
|
||
For Each element In sid<br>
|
||
Debug.Print Hex(element)<br>
|
||
Next</font></small></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><font face="Verdana" color="#0080C0"><strong><small><a name="user_group"></a>Getting
|
||
groups a user belongs to</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>Set usr = GetObject("WinNT://INDEPENDENCE/jsmith,user")<br>
|
||
For each grp in usr.Groups<br>
|
||
Debug.Print grp.Name<br>
|
||
Next</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="user_rename"></a><font face="Verdana" color="#0080C0"><strong><small>Renaming
|
||
a User</small></strong></font></p>
|
||
|
||
<p><font face="Verdana" color="#000000"><small>Renaming a user is similar to <a
|
||
href="start.htm#rename">renaming an object</a>.</small></font></p>
|
||
|
||
<p><small><font face="Verdana">Set dom = GetObject("WinNT://INDEPENDENCE")<br>
|
||
Set usr = dom.MoveHere("WinNT://INDEPENDENCE/jsmith,user", "jjohnson")<br>
|
||
usr.FullName = "Jane Johnson"<br>
|
||
usr.SetInfo</font></small></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="usr_delete"></a><font face="Verdana" color="#0080C0"><strong><small>Deleting a
|
||
User</small></strong></font></p>
|
||
|
||
<p><font face="Verdana" color="#000000"><small>Deleting a user is similar to <a
|
||
href="start.htm#delete">deleting an object</a>.</small></font></p>
|
||
|
||
<p><small><font face="Verdana">Set dom = GetObject("WinNT://INDEPENDENCE")<br>
|
||
dom.Delete "user", "jjohnson"</font></small></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_user">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="group_create"></a><font face="Verdana" color="#0080C0"><strong><small>Creating
|
||
a Group</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>This code snippet shows how to create a local group in a domain.<br>
|
||
|
||
<br>
|
||
|
||
Set dom = GetObject("WinNT://INDEPENDENCE")<br>
|
||
Set grp = dom.Create("group", "DSys")<br>
|
||
grp.Put "groupType", ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP<br>
|
||
grp.Description = "Distributed System Group"<br>
|
||
grp.SetInfo<br>
|
||
|
||
<br>
|
||
<br>
|
||
|
||
This shows how to create a global group in a domain.<br>
|
||
|
||
<br>
|
||
|
||
Set dom = GetObject("WinNT://INDEPENDENCE")<br>
|
||
Set grp = dom.Create("group", "PM")<br>
|
||
grp.Put "groupType", ADS_GROUP_TYPE_GLOBAL_GROUP<br>
|
||
grp.Description = "Program Managers"<br>
|
||
grp.SetInfo<br>
|
||
|
||
<br>
|
||
<br>
|
||
|
||
And finally, this snippet shows how to create a local group in a computer.<br>
|
||
|
||
<br>
|
||
|
||
Set comp = GetObject("WinNT://SEATTLE,computer")<br>
|
||
Set grp = comp.Create("group", "TheSmiths")<br>
|
||
grp.Put "groupType", ADS_GROUP_TYPE_LOCAL_GROUP<br>
|
||
grp.Description = "The Smiths Family Member"<br>
|
||
grp.SetInfo</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_group">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="group_add_user"></a><font face="Verdana" color="#0080C0"><strong><small>Adding
|
||
a User to a Group</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>'--- Adding a user in a
|
||
local domain or global group.<br>
|
||
|
||
<br>
|
||
|
||
Set grp = GetObject("WinNT://INDEPENDENCE/DSys,group")<br>
|
||
grp.Add ("WinNT://INDEPENDENCE/JSmith")<br>
|
||
<br>
|
||
|
||
<br>
|
||
|
||
'--- Adding a user in a
|
||
local group in a computer.<br>
|
||
|
||
<br>
|
||
|
||
Set comp = GetObject("WinNT://SEATTLE,computer")<br>
|
||
Set grp = comp.GetObject("group", "TheSmiths")<br>
|
||
grp.Add ("WinNT://INDEPENDENCE/JSmith")</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_group">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="group_add"></a><font face="Verdana" color="#0080C0"><strong><small>Adding a
|
||
Group to a Group</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>A global group can be added to a local group in a
|
||
Windows NT 4.0 domain. Note that in the Windows 2000 domain environment, you can nest a
|
||
group.</small></font></p>
|
||
|
||
<p><small><font face="Verdana">Set grp = GetObject("WinNT://INDEPENDENCE/DSys,group")<br>
|
||
|
||
grp.Add ("WinNT://INDEPENDENCE/PM,group")</font></small></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_group">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="group_enumerate"></a><font face="Verdana" color="#0080C0"><strong><small>Enumerating
|
||
Group in a Domain or Computer</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>'--- Enumerating groups in a domain.<br>
|
||
|
||
<br>
|
||
|
||
Set dom = GetObject("WinNT://INDEPENDENCE")<br>
|
||
dom.Filter = Array("Group")<br>
|
||
|
||
<br>
|
||
|
||
'--- Enumerating a local group.
|
||
|
||
<br>
|
||
|
||
<br>
|
||
|
||
Debug.Print "Local Groups---"<br>
|
||
For Each grp In dom<br>
|
||
If (grp.GroupType = ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP) Then<br>
|
||
Debug.Print grp.Name<br>
|
||
End If<br>
|
||
Next<br>
|
||
|
||
<br>
|
||
|
||
'--- Enumerating a global group.
|
||
|
||
<br>
|
||
|
||
<br>
|
||
|
||
Debug.Print "Global Groups---"<br>
|
||
For Each grp In dom<br>
|
||
If (grp.GroupType = ADS_GROUP_TYPE_GLOBAL_GROUP) Then<br>
|
||
Debug.Print grp.Name<br>
|
||
End If<br>
|
||
Next<br>
|
||
|
||
<br>
|
||
|
||
'--- Enumerating groups in a computer.<br>
|
||
|
||
<br>
|
||
|
||
Set comp = GetObject("WinNT://SEATTLE,computer")<br>
|
||
comp.Filter = Array("Group")<br>
|
||
|
||
<br>
|
||
|
||
'A local group consists of all groups in a computer<br>
|
||
|
||
Debug.Print "Groups:"<br>
|
||
For Each grp In comp<br>
|
||
Debug.Print grp.Name<br>
|
||
Next
|
||
|
||
</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_group">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="group_member"></a><font face="Verdana" color="#0080C0"><strong><small>Enumerating
|
||
Group Membership</small></strong></font></p>
|
||
|
||
<font face="Verdana"><small>Local groups may contain global groups.</small></font>
|
||
<p><font face="Verdana"><small>Set grp = GetObject("WinNT://INDEPENDENCE/DSys,group")<br>
|
||
|
||
For Each member In grp.Members<br>
|
||
Debug.Print member.Name & " (" & member.Class
|
||
& ")"
|
||
|
||
</small></font></p>
|
||
<p><font face="Verdana">
|
||
|
||
<small>
|
||
|
||
<br>
|
||
|
||
'Global group memberships may also be enumerated.<br>
|
||
|
||
<br>
|
||
|
||
If (member.Class = "Group") Then<br>
|
||
|
||
For Each obj In
|
||
member.Members<br>
|
||
|
||
|
||
Debug.Print " " & obj.Name & " (" & obj.Class &
|
||
")"<br>
|
||
|
||
Next<br>
|
||
|
||
End If<br>
|
||
|
||
<br>
|
||
|
||
Next</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_group">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="group_remove"></a><font face="Verdana" color="#0080C0"><strong><small>Removing
|
||
a Member from Group</small></strong></font></p>
|
||
|
||
<p><small><font face="Verdana">Set grp = GetObject("WinNT://INDEPENDENCE/PM,group")<br>
|
||
|
||
grp.Remove ("WinNT://INDEPENDENCE/ChristyH")</font></small></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_group">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="group_ismember"></a><font face="Verdana" color="#0080C0"><strong><small>Finding
|
||
Out if a User or Group is a Member of a Group</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>
|
||
Set grp = GetObject("WinNT://INDEPENDENCE/DSys,group")<br>
|
||
If (grp.IsMember("WinNT://INDEPENDENCE/JSmith")) Then<br>
|
||
Debug.Print "Yes"<br>
|
||
Else<br>
|
||
Debug.Print "No"<br>
|
||
End If</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_group">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="computer"></a><font face="Verdana" color="#0080C0"><strong><small>Connecting
|
||
to a Computer</small></strong></font></p>
|
||
<p><font face="Verdana"><small>
|
||
|
||
Set comp = GetObject("WinNT://INDEPENDENCE/SEATTLE,computer")<br>
|
||
Debug.Print comp.Division<br>
|
||
Debug.Print comp.OperatingSystem<br>
|
||
Debug.Print comp.OperatingSystemVersion<br>
|
||
Debug.Print comp.Owner<br>
|
||
Debug.Print comp.Processor<br>
|
||
Debug.Print comp.ProcessorCount</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_computer">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="service_enumerate"></a><font face="Verdana" color="#0080C0"><strong><small>Enumerating
|
||
Services in a Computer</small></strong></font><small><font face="Verdana"><br>
|
||
|
||
<br>
|
||
|
||
Set comp = GetObject("WinNT://INDEPENDENCE/SEATTLE,computer")<br>
|
||
comp.Filter = Array("Service")<br>
|
||
|
||
<br>
|
||
|
||
For Each svc In comp<br>
|
||
Debug.Print svc.Name & " " & svc.DisplayName<br>
|
||
Next</font></small></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_computer">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="service_display"></a><strong><font face="Verdana" color="#0080C0"><small>Displaying
|
||
the Service's Properties</small></font></strong></p>
|
||
|
||
<p><font face="Verdana"><small>This code snippet shows how to display a service's properties,
|
||
as defined in winnt.h.</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>
|
||
|
||
Const SERVICE_BOOT_START = &H0<br>
|
||
Const SERVICE_SYSTEM_START = &H1<br>
|
||
Const SERVICE_AUTO_START = &H2<br>
|
||
Const SERVICE_DEMAND_START = &H3<br>
|
||
Const SERVICE_DISABLED = &H4<br>
|
||
|
||
<br>
|
||
|
||
'--- Error control type<br>
|
||
|
||
<br>
|
||
|
||
Const SERVICE_ERROR_IGNORE = &H0<br>
|
||
Const SERVICE_ERROR_NORMAL = &H1<br>
|
||
Const SERVICE_ERROR_SEVERE = &H2<br>
|
||
Const SERVICE_ERROR_CRITICAL = &H3<br>
|
||
|
||
<br>
|
||
|
||
Const SERVICE_KERNEL_DRIVER = &H1<br>
|
||
Const SERVICE_FILE_SYSTEM_DRIVER = &H2<br>
|
||
Const SERVICE_ADAPTER = &H4<br>
|
||
Const SERVICE_RECOGNIZER_DRIVER = &H8<br>
|
||
|
||
<br>
|
||
|
||
Const SERVICE_DRIVER = &HB<br>
|
||
Const SERVICE_WIN32_OWN_PROCESS = &H10<br>
|
||
Const SERVICE_WIN32_SHARE_PROCESS = &H20<br>
|
||
Const SERVICE_WIN32 = &H30<br>
|
||
Const SERVICE_INTERACTIVE_PROCESS = &H100<br>
|
||
|
||
<br>
|
||
|
||
Set comp = GetObject("WinNT://SEATTLE,computer")<br>
|
||
Set svc = comp.GetObject("Service", "Browser")</small><br>
|
||
|
||
<small>
|
||
|
||
<br>
|
||
|
||
Debug.Print "Display Name: " & svc.DisplayName<br>
|
||
Debug.Print "Order Group: " & svc.LoadOrderGroup<br>
|
||
Debug.Print "Host Name: " & svc.HostComputer<br>
|
||
|
||
<br>
|
||
|
||
s = "Startup: "<br>
|
||
|
||
<br>
|
||
|
||
Select Case svc.StartType<br>
|
||
Case SERVICE_BOOT_START<br>
|
||
s = s + "Boot Start"<br>
|
||
Case SERVICE_SYSTEM_START<br>
|
||
s = s + "System Start"<br>
|
||
Case SERVICE_AUTO_START<br>
|
||
s = s + "Automatic"<br>
|
||
Case SERVICE_DEMAND_START<br>
|
||
s = s + "Manual"<br>
|
||
Case SERVICE_DISABLED<br>
|
||
s = s + "Disabled"<br>
|
||
Case Else<br>
|
||
s = s + "Unknown"<br>
|
||
End Select<br>
|
||
Debug.Print s<br>
|
||
|
||
<br>
|
||
|
||
'Dependencies<br>
|
||
|
||
<br>
|
||
|
||
Debug.Print "Dependencies: "<br>
|
||
For Each dpc In svc.Dependencies<br>
|
||
Debug.Print " " & dpc<br>
|
||
Next
|
||
|
||
<br>
|
||
|
||
<br>
|
||
|
||
'Service Type</small></font>
|
||
<br>
|
||
|
||
<font face="Verdana">
|
||
|
||
<small>
|
||
|
||
<br>
|
||
|
||
s = "Service Type: "</small><br>
|
||
|
||
<small>
|
||
|
||
<br>
|
||
|
||
Select Case svc.ServiceType<br>
|
||
Case SERVICE_KERNEL_DRIVER<br>
|
||
s = s + "Kernel Driver"<br>
|
||
Case SERVICE_FILE_SYSTEM_DRIVER<br>
|
||
s = s + "File System Driver"<br>
|
||
Case SERVICE_ADAPTER<br>
|
||
s = s + "Adapter"<br>
|
||
Case SERVICE_RECOGNIZER_DRIVER<br>
|
||
s = s + "Recognizer Driver"<br>
|
||
Case SERVICE_WIN32_OWN_PROCESS<br>
|
||
s = s + "Win32 Process"<br>
|
||
Case SERVICE_WIN32_SHARE_PROCESS<br>
|
||
s = s + "Win32 Share Process"<br>
|
||
Case SERVICE_WIN32<br>
|
||
s = s + "Win32"<br>
|
||
Case SERVICE_INTERACTIVE_PROCESS<br>
|
||
s = s + "Interactive Process"<br>
|
||
End Select<br>
|
||
Debug.Print s<br>
|
||
|
||
<br>
|
||
|
||
'Error Control<br>
|
||
|
||
<br>
|
||
|
||
s = "Error Control: "<br>
|
||
Select Case svc.ErrorControl<br>
|
||
|
||
<br>
|
||
|
||
Case SERVICE_ERROR_IGNORE<br>
|
||
s = s + "Service ignores error"<br>
|
||
Case SERVICE_ERROR_NORMAL<br>
|
||
s = s + "No Error"<br>
|
||
Case SERVICE_ERROR_SEVERE<br>
|
||
s = s + "Severe error"<br>
|
||
Case SERVICE_ERROR_CRITICAL<br>
|
||
s = s + "Critical error"<br>
|
||
Case Else<br>
|
||
s = s + "Unknown"<br>
|
||
End Select<br>
|
||
Debug.Print s</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>
|
||
|
||
Back to <a href="#top_computer">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="service_operations"></a><font face="Verdana" color="#0080C0"><strong><small>Stopping,
|
||
Starting, and Pausing a Service</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>
|
||
|
||
Set comp = GetObject("WinNT://SEATTLE,computer")<br>
|
||
Set svcOp = comp.GetObject("Service", "Browser")<br>
|
||
|
||
<br>
|
||
|
||
'Stopping a service.<br>
|
||
|
||
<br>
|
||
|
||
svcOp.Stop<br>
|
||
|
||
<br>
|
||
|
||
'Starting a service.<br>
|
||
|
||
<br>
|
||
|
||
svcOp.Start<br>
|
||
|
||
<br>
|
||
|
||
'Pausing a service.<br>
|
||
|
||
<br>
|
||
|
||
svcOp.Pause</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_computer">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="fileshare_enumerate"></a><font face="Verdana" color="#0080C0"><strong><small>Enumerating
|
||
File Shares in a Computer</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>
|
||
|
||
Set comp = GetObject("WinNT://SEATTLE,computer")<br>
|
||
Set svc = GetObject(comp.ADsPath & "/" & "LanmanServer")<br>
|
||
For Each fileShare In svc<br>
|
||
Debug.Print fileShare.Name & " " & " " &
|
||
fileShare.CurrentUserCount & " " & fileShare.Path<br>
|
||
Next</small></font></p>
|
||
<p><font face="Verdana"><small>Back to <a href="#top_computer">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="fileshare_create"></a><font face="Verdana" color="#0080C0"><strong><small>Creating
|
||
a File Share in a Computer</small></strong></font></p>
|
||
<p><small><font face="Verdana">
|
||
|
||
Set comp = GetObject("WinNT://SEATTLE,computer")<br>
|
||
Set svc = GetObject(comp.ADsPath & "/" & "LanmanServer")<br>
|
||
Set fileShare = svc.Create("FileShare", "public")<br>
|
||
fileShare.Path = "c:\public"<br>
|
||
fileShare.SetInfo
|
||
</font></small></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_computer">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="fileshare_delete"></a><font face="Verdana" color="#0080C0"><strong><small>Deleting
|
||
a File Share</small></strong></font></p>
|
||
<p><font face="Verdana"><small>
|
||
|
||
Set comp = GetObject("WinNT://SEATTLE,computer")<br>
|
||
Set svc = GetObject(comp.ADsPath & "/" & "LanmanServer")<br>
|
||
svc.Delete "FileShare", "public"</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_computer">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="session"></a><font face="Verdana" color="#0080C0"><strong><small>Enumerating
|
||
Sessions in a Computer</small></strong></font></p>
|
||
|
||
<p><small><font face="Verdana">Dim fileSvc As IADsFileService<br>
|
||
Dim session As IADsSession</font></small><br>
|
||
<small><font face="Verdana"><br>
|
||
Set comp = GetObject("WinNT://SEATTLE,computer")<br>
|
||
Set fileSvc = GetObject(comp.ADsPath & "/" & "LanmanServer")<br>
|
||
For Each session In fileSvc.Sessions<br>
|
||
Debug.Print session.Name & " " &
|
||
session.ConnectTime<br>
|
||
Next</font></small></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_computer">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="resource"></a><font face="Verdana" color="#0080C0"><strong><small>Enumerating
|
||
Resources in a Computer</small></strong></font></p>
|
||
<p><font face="Verdana"><small>
|
||
|
||
Set comp = GetObject("WinNT://SEATTLE,computer")<br>
|
||
Set fileSvc = GetObject(comp.ADsPath & "/" & "LanmanServer")<br>
|
||
For Each resource In fileSvc.Resources<br>
|
||
Debug.Print resource.Name & " - " & resource.User<br>
|
||
Next</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_computer">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><font face="Verdana" color="#0080C0"><strong><small><a name="computer_creating"></a>Creating
|
||
a Machine Account</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>machinename = "mymachine"<br>
|
||
Set oProv = GetObject("WinNT:")<br>
|
||
Set oTarg = oProv.OpenDSObject("WinNT://myDomain", "domain\user","password",ADS_SECURE_AUTHENTICATION)<br>
|
||
Set oComp = oTarg.Create("computer", machinename)<br>
|
||
oComp.SetInfo</small></font>
|
||
|
||
<br>
|
||
|
||
<font face="Verdana">
|
||
|
||
<small>
|
||
|
||
<br>
|
||
|
||
'--- Rebind as a user and set the
|
||
initial password.
|
||
|
||
<br>
|
||
|
||
<br>
|
||
|
||
Set oCompUser = GetObject("WinNT://domain/" & machinename
|
||
"$,user")<br>
|
||
sPwd = machinename<br>
|
||
sPwd = StrConv(sPwd, vbLowerCase)<br>
|
||
oCompUser.SetPassword sPwd<br>
|
||
oCompUser.SetInfo</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_computer">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="fileshare_security"></a><font face="Verdana" color="#0080C0"><strong><small>Setting
|
||
File Share Security</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>Setting file share security is supported
|
||
in the <a href="rtk.htm">ADSI Resource Tool Kit</a>.</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_computer">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="file"></a><font face="Verdana" color="#0080C0"><strong><small>Setting File
|
||
security</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>Setting file security is supported in the
|
||
<a href="rtk.htm">ADSI Resource Tool Kit</a>.</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>Back to <a href="#top_file">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="print_enumerate"></a><font face="Verdana" color="#0080C0"><strong><small>Enumerating
|
||
Print Queues in a Computer</small></strong></font></p>
|
||
|
||
<p><font face="Verdana"><small>computerName = "MSPRINT44"<br>
|
||
printQueueName = "CORPF"<br>
|
||
|
||
<br>
|
||
|
||
Set comp = GetObject("WinNT://" & computerName & ",computer")<br>
|
||
|
||
<br>
|
||
|
||
comp.Filter = Array("PrintQueue")<br>
|
||
|
||
<br>
|
||
|
||
<br>
|
||
|
||
'--- Enumerating a Printer in a computer.<br>
|
||
|
||
<br>
|
||
|
||
For Each printQueue In comp<br>
|
||
|
||
<br>
|
||
|
||
s = printQueue.Name & " " & printQueue.Description & " ("
|
||
& printQueue.PrinterPath & ")"<br>
|
||
'Debug.Print printQueue.status<br>
|
||
|
||
<br>
|
||
|
||
'--- QI the PrintQueueOperations (this is optional step in VB/VBScript).<br>
|
||
|
||
<br>
|
||
|
||
Set printQOps = printQueue<br>
|
||
s = s & "Status: " & GetPrintStatus(printQueue.status)<br>
|
||
Debug.Print s ' Report the printQueue and Printer status<br>
|
||
Next</small></font></p>
|
||
|
||
<p><font face="Verdana"><small>You can find the source code for this example
|
||
at <a href="../samples/winnt/PrintQueue/vb">\\samples\WinNT\PrintQueue</a>.
|
||
|
||
<br>
|
||
<br>
|
||
|
||
Back to <a href="#top_file">top</a>.</small></font></p>
|
||
|
||
<p> </p>
|
||
|
||
<p><a name="print_job"><font face="Verdana" color="#0080C0"><strong><small>Listing Print
|
||
Jobs in a Queue</small></strong></font></a></p>
|
||
|
||
<font face="Verdana"><small>
|
||
Dim printQueue As IADsPrintQueue<br>
|
||
Dim printQOps As IADsPrintQueueOperations<br>
|
||
Dim printJob As IADsPrintJob<br>
|
||
Dim printJobOps As IADsPrintJobOperations<br>
|
||
|
||
<br>
|
||
|
||
'--- Bind to a printer queue.
|
||
|
||
<br>
|
||
|
||
<br>
|
||
|
||
Set comp = GetObject("WinNT://" & computerName & ",computer")<br>
|
||
Set printQueue = comp.GetObject("PrintQueue", printQueueName)<br>
|
||
|
||
<br>
|
||
|
||
'--- Get print queue characteristics.
|
||
|
||
<br>
|
||
|
||
<br>
|
||
|
||
Debug.Print printQueue.Name & " " & printQueue.Description & "
|
||
(" & printQueue.PrinterPath & ")"<br>
|
||
Debug.Print s
|
||
<br>
|
||
|
||
<br>
|
||
|
||
'--- Switch to print queue operation.<br>
|
||
|
||
<br>
|
||
|
||
Set printQOps = printQueue<br>
|
||
Debug.Print "Status: " & GetPrintStatus(printQueue.status)<br>
|
||
|
||
<br>
|
||
|
||
'--- Get print jobs for this specific queue.<br>
|
||
|
||
<br>
|
||
|
||
Debug.Print "--- Jobs in the queue ----- "<br>
|
||
For Each printJob In printQOps.PrintJobs<br>
|
||
Debug.Print printJob.Description & " " & printJob.User & "
|
||
" & printJob.Priority<br>
|
||
Set printJobOps = printJob<br>
|
||
Debug.Print "Page printed: " & printJobOps.PagesPrinted & "Page(s)
|
||
" & GetJobStatus(printJobOps.status)<br>
|
||
Debug.Print "-----"<br>
|
||
Next
|
||
</small></font>
|
||
|
||
<p><font face="Verdana"><small>You can find the source code for this example
|
||
at <a href="../samples/winnt/PrintQueue/vb">\\samples\WinNT\PrintQueue</a>.<br>
|
||
|
||
<br>
|
||
|
||
Back to <a href="#top_file">top</a>.</small></font></p>
|
||
|
||
<br>
|
||
|
||
<p> </p>
|
||
|
||
</td>
|
||
|
||
</tr>
|
||
|
||
</table>
|
||
</body>
|
||
</html>
|