在Delphi 5.0中如何获得NT 的用户列表,以及用户的目录访问列表?急!急!急!急!急!急!(200分)

  • 主题发起人 主题发起人 yblldl
  • 开始时间 开始时间
Y

yblldl

Unregistered / Unconfirmed
GUEST, unregistred user!
在Delphi 5.0中:<br>1、如何获得NT 的用户列表?<br>2、以及用户的目录访问列表?
 
下一个nttools控件试试<br>http://www.torry.net/vcl/system/nt/nt.zip<br><br>wellcome to vcl.xilubbs.com
 
我下载了那个“http://www.torry.net/vcl/system/nt/nt.zip” 可是还是得不到<br>1、如何获得NT 的用户列表?<br>2、以及用户的目录访问列表?<br>到是能够得到一些其他NT用户的信息,能不能告诉我<br>1、如何获得NT 的用户列表?<br>2、以及用户的目录访问列表?<br><br>
 
是不是该调用API啊,看一看windows API大全,或者用程序来运行net user命令得到用户列表。
 
调用api 函数wnetopenenum()和wnetenumresource可以列举网络资源。<br>wnetopenenum()用于获取一个网络资源句柄作为wnetenumresource列举网络资源的依据
 
look,取得nt上的用户列表<br>unit Unit1;<br>{ &nbsp;这是一个演示如何去获取目标NT计算机上用户列表的程序,<br>&nbsp; 由于是为了演示原理,所以没有使用多线程,也没有考虑太高<br>&nbsp; 的强壮性,希望诸位海涵。欢迎和我联系<br>&nbsp; Vader Yang<br>&nbsp; ciert@soim.net}<br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls, ComCtrls, ExtCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; EdtHostName: TEdit;<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; Label1: TLabel;<br>&nbsp; &nbsp; cpDomain: TLabel;<br>&nbsp; &nbsp; lbAdmin: TLabel;<br>&nbsp; &nbsp; Label3: TLabel;<br>&nbsp; &nbsp; Label2: TLabel;<br>&nbsp; &nbsp; ListBox1: TListBox;<br>&nbsp; &nbsp; Bevel1: TBevel;<br>&nbsp; &nbsp; StatusBar1: TStatusBar;<br>&nbsp; &nbsp; Panel1: TPanel;<br>&nbsp; &nbsp; Button2: TButton;<br>&nbsp; &nbsp; Button3: TButton;<br>&nbsp; &nbsp; Button4: TButton;<br>&nbsp; &nbsp; SaveDialog1: TSaveDialog;<br>&nbsp; &nbsp; Options: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure Button3Click(Sender: TObject);<br>&nbsp; &nbsp; procedure Button4Click(Sender: TObject);<br>&nbsp; &nbsp; procedure Button2Click(Sender: TObject);<br>&nbsp; &nbsp; procedure OptionsClick(Sender: TObject);<br>&nbsp; &nbsp; procedure FormShow(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br>&nbsp; seedline:String;<br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br><br>var<br>&nbsp; &nbsp; seaNetResource:NETRESOURCE;<br>&nbsp; &nbsp; seaResult:DWORD;<br>&nbsp; &nbsp; seaAccessBuffer:string[255];<br>&nbsp; &nbsp; seaAccessBufferLength:DWORD;<br>&nbsp; &nbsp; sidbuffer:string[255];<br>&nbsp; &nbsp; lpAccessBuffer:PChar;<br>&nbsp; &nbsp; seaSID:PSID;<br>&nbsp; &nbsp; seaSIDlength:DWORD;<br>&nbsp; &nbsp; seaReferencedDomainName:string[255];<br>&nbsp; &nbsp; seaReferencedDomainNameLength:DWORD;<br>&nbsp; &nbsp; lpReferencedDomainName:PChar;<br>&nbsp; &nbsp; seaSIDnameuse:SID_NAME_USE;<br>&nbsp; &nbsp; tempPchar:Pchar;<br>&nbsp; &nbsp; SidSubCount:PUCHAR;<br>&nbsp; &nbsp; i,j:integer;<br>&nbsp; &nbsp; StoreCount:byte;<br>&nbsp; &nbsp; tempPDWORD:PDWORD;<br>&nbsp; &nbsp; tempDWORD:DWORD;<br>&nbsp; &nbsp; storeSIDsub: array [0..8] of Integer;<br>&nbsp; &nbsp; seaSidIdentify:PSIDIdentifierAuthority;<br>&nbsp; &nbsp; newSID:PSID;<br>&nbsp; &nbsp; seaAccountBuffer:String[255];<br>&nbsp; &nbsp; pAccountName:LPTSTR;<br>&nbsp; &nbsp; AccountLength:DWORD;<br>&nbsp; &nbsp; BlResult:Boolean;<br>const<br>&nbsp; &nbsp; AccountType:array [0..8] of string=('','User','Group','Domain','alias',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'WelknowGroup','Deleted','Invalid','Unknown');<br>begin<br>&nbsp; &nbsp; &nbsp;Button1.Enabled:=False;<br>&nbsp; &nbsp; lpAccessBuffer:=@seaAccessBuffer;<br>&nbsp; &nbsp; lpReferencedDomainName:=@seaReferencedDomainName;<br>&nbsp; &nbsp; seaSID:=@sidbuffer;<br>&nbsp; &nbsp; seaAccessBufferLength:=64;<br>&nbsp; &nbsp; seaSIDLength:=255;<br>&nbsp; &nbsp; seaReferencedDomainNameLength:=255;<br>&nbsp; &nbsp; seaNetResource.dwScope:=RESOURCE_GLOBALNET;<br>&nbsp; &nbsp; seaNetResource.dwType:=RESOURCETYPE_ANY;<br>&nbsp; &nbsp; seaNetResource.lpLocalName:=PChar('');<br>&nbsp; &nbsp; seaNetResource.lpRemoteName:=PChar('//'+EdtHostName.Text+'/IPC$');<br>&nbsp; &nbsp; seaNetResource.lpProvider:=PChar('');<br>&nbsp; &nbsp; seaResult:=WNetAddConnection2(seaNetResource,PChar(''),PChar(''),CONNECT_PROMPT);<br>&nbsp; &nbsp; if seaResult=NO_ERROR then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if LookupAccountName(PChar('//'+EdtHostName.Text),Pchar(seedline),seaSID,seaSIDlength,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lpReferencedDomainName,seaReferencedDomainNamelength,seaSIDnameuse)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cpDomain.Caption:=string(lpReferencedDomainName);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; seaSidIdentify:=GetSidIdentifierAuthority(seaSID);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SidSubCount:=GetSidSubAuthorityCount(seaSID);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StoreCount:=SidSubCount^;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for i:=0 to Integer(StoreCount)-1 do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tempPDWORD:=GetSidSubAuthority(seaSID,i);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;storeSIDsub:=tempPDWORD^;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //start to get username<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pAccountName:=@seaAccountBuffer ;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; seaReferencedDomainNameLength:=255;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AccountLength:=255;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; storeSIDsub[StoreCount-1]:=500;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if AllocateAndInitializeSid(seaSidIdentify^,SidSubCount^,StoreSidSub[0],<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StoreSidSub[1],StoreSidSub[2],StoreSidSub[3],StoreSidSub[4],<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StoreSidSub[5],StoreSidSub[6],StoreSidSub[7],newSID) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if LookupAccountSid(PChar('//'+EdtHostName.Text),newsid,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pAccountName,AccountLength,lpReferencedDomainName,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;seaReferencedDomainNameLength,seaSIDnameuse)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lbAdmin.Caption:=String(pAccountName);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ListBox1.Items.Add('//'+lpReferencedDomainName+'/'+pAccountName+' &nbsp; &nbsp; &nbsp; Built-in Admin');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FreeSid(newSID);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//tempDWORD:=GetLastError;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;j:=1;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;i:=1000;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;while j&lt;=30 do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; seaReferencedDomainNamelength:=255;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AccountLength:=255;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StoreSidSub[StoreCount-1]:=i;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AllocateAndInitializeSid(seaSidIdentify^,SidSubCount^,StoreSidSub[0],<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;StoreSidSub[1],StoreSidSub[2],StoreSidSub[3],StoreSidSub[4],<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;StoreSidSub[5],StoreSidSub[6],StoreSidSub[7],newSID);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if LookupAccountSid(PChar('//'+EdtHostName.Text),newsid,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pAccountName,AccountLength,lpReferencedDomainName,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;seaReferencedDomainNameLength,seaSIDnameuse)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if seaSIDnameuse=sidTypeInvalid then j:=j+1<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if seaSIDnameuse&lt;&gt;sidTypeDeletedAccount then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j:=0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ListBox1.Items.Add('//'+lpReferencedDomainName+<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'/'+pAccountName+' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'+AccountType[seaSIDnameuse]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StatusBar1.SimpleText:=pAccountName;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;j:=j+1;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Application.ProcessMessages;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i:=i+1;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FreeSID(newsid);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else ShowMessage('Cannot locate sid infomation!');<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; else ShowMessage('Connection Error!');<br>&nbsp; &nbsp; WNetCancelConnection2(PChar('//'+EdtHostName.Text+'/IPC$'),0,true);<br>&nbsp; &nbsp; Button1.Enabled:=True;<br>end;<br><br>procedure TForm1.Button3Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp; &nbsp; ListBox1.Items.Clear;<br>end;<br><br>procedure TForm1.Button4Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp; &nbsp;SaveDialog1.Execute;<br>&nbsp; &nbsp; &nbsp;if SaveDialog1.FileName&lt;&gt;'' then ListBox1.Items.SaveToFile(SaveDialog1.FileName);<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp; &nbsp;ShowMessage('如果有任何意见或者咨询'#13#10'请与ciert@soim.net联系');<br>end;<br><br>procedure TForm1.OptionsClick(Sender: TObject);<br>begin<br>&nbsp; &nbsp; &nbsp;seedline:=InputBox('Input seed','Input seed(recommend "domain users" or "guest")','guest');<br>end;<br><br>procedure TForm1.FormShow(Sender: TObject);<br>begin<br>&nbsp; &nbsp; seedline:='guest';<br>end;<br><br>end.<br>
 
感谢honghs如此详细的解答,我正在测试!
 
多人接受答案了。
 
后退
顶部