powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Microsoft Access [игнор отключен] [закрыт для гостей] / Список компьютеров и пользователей в сети
9 сообщений из 9, страница 1 из 1
Список компьютеров и пользователей в сети
    #32447370
Фотография Polev
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Подскажите, как программно получить сабж?
...
Рейтинг: 0 / 0
Список компьютеров и пользователей в сети
    #32447756
Фотография Geo
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Посмотри faq по сжатию БД, там список кого-то получают. Только не помню, "кого".
...
Рейтинг: 0 / 0
Список компьютеров и пользователей в сети
    #32448542
Фотография Polev
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Блин.... Я же в этом уже разбирался, но потерял результаты и не помню как это делал.... Кажется через WSH....
...
Рейтинг: 0 / 0
Список компьютеров и пользователей в сети
    #32448714
Фотография Senin Viktor
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
/topic/56222\r
В последнем посте - все константы API функции - что они делают - ясно из их названия, сами значения констант брать из API Text Viewer
...
Рейтинг: 0 / 0
Список компьютеров и пользователей в сети
    #32448739
Фотография Polev
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
СПАСИБО!!!!!
...
Рейтинг: 0 / 0
Список компьютеров и пользователей в сети
    #32449000
Фотография Polev
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Только вот что... Список компов я получил, а список пользователей можно? Ну в смысле учетных записей?
...
Рейтинг: 0 / 0
Список компьютеров и пользователей в сети
    #32449125
OldPferd
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Поищи по форуму (и по MS SQL) про ADSI, LDAP

На эту тему сам как-то использовал такое
(должна быть ссылка на Active DS Type Library):

Private Const ADS_SCOPE_BASE = 0
Private Const ADS_SCOPE_ONELEVEL = 1
Private Const ADS_SCOPE_SUBTREE = 2
Private Const ADS_CHASE_REFERRALS_NEVER = 0
Private Const ADS_CHASE_REFERRALS_SUBORDINATE = &H20
Private Const ADS_CHASE_REFERRALS_EXTERNAL = &H40
Private Const ADS_CHASE_REFERRALS_ALWAYS = ADS_CHASE_REFERRALS_SUBORDINATE Or ADS_CHASE_REFERRALS_EXTERNAL

Function SamAccountNameGet(SamAccountName As String, SamAccountNameProp As String) As String
Dim sMsg As String, sObjectDN As String, sDomain As String
Dim rootDSE As IADs, oIADs As IADs, con As Connection, rs As Recordset, Com As Command
SamAccountNameGet = ""
On Error GoTo Err_
Set rootDSE = GetObject("LDAP://RootDSE")
sDomain = rootDSE.Get("defaultNamingContext")
sObjectDN = "LDAP://" & sDomain
Set rootDSE = Nothing
Set oIADs = GetObject(sObjectDN)
Set con = New Connection
con.Provider = "ADsDSOObject"
con.Open "Active Directory Provider"

Set Com = New Command
Set Com.ActiveConnection = con
Com.CommandText = "select " & SamAccountNameProp & " from '" & oIADs.ADsPath & "' where samaccountname='" & SamAccountName & "'"
Com.Properties("Page Size") = 1000
Com.Properties("Timeout") = 30
Com.Properties("searchscope") = ADS_SCOPE_SUBTREE
Com.Properties("Chase referrals") = ADS_CHASE_REFERRALS_EXTERNAL
Com.Properties("Cache Results") = False
Com.Properties("Size Limit") = 1

Set rs = New Recordset
Set rs = Com.Execute
If rs.EOF Then
MsgBox "Учетная запись " & SamAccountName & " не найдена", vbCritical, sDomain
Else
SamAccountNameGet = Nz(rs.Fields(SamAccountNameProp), "")
End If
rs.Close
Exit_:
Set rs = Nothing
Set Com = Nothing
Set con = Nothing
Set oIADs = Nothing
Exit Function
Err_:
Errmsg_cnn con
Resume Exit_
End Function
...
Рейтинг: 0 / 0
Список компьютеров и пользователей в сети
    #32449188
Фотография Senin Viktor
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Только навряд ли сисадмин даст права на чтение - во всяком случае у меня в сети их нет.
Возможно, есть другой способ, как Проводник ихполучает
...
Рейтинг: 0 / 0
Список компьютеров и пользователей в сети
    #32449244
Фотография Senin Viktor
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
вот нашел - сразу несколько функций для работы с юзерами и группами
(Knowledge Base:HOWTO: Call LanMan Services from 32-bit Visual Basic Apps (Q159498))

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
213.
214.
215.
216.
217.
218.
219.
220.
221.
222.
223.
224.
225.
226.
227.
228.
229.
230.
231.
232.
233.
234.
235.
236.
237.
238.
239.
240.
241.
242.
243.
244.
245.
246.
247.
248.
249.
250.
251.
252.
253.
254.
255.
256.
257.
258.
259.
260.
261.
262.
263.
264.
265.
266.
267.
268.
269.
270.
271.
272.
273.
274.
275.
276.
277.
278.
279.
280.
281.
282.
283.
284.
285.
286.
287.
288.
289.
290.
291.
292.
293.
294.
295.
296.
297.
298.
299.
300.
301.
302.
303.
304.
305.
306.
307.
308.
309.
310.
311.
312.
313.
314.
315.
316.
317.
318.
319.
320.
321.
322.
323.
324.
325.
326.
327.
328.
329.
330.
331.
332.
333.
334.
335.
336.
337.
338.
339.
340.
341.
342.
343.
344.
345.
346.
347.
348.
349.
350.
351.
352.
   Option Explicit
   Option Base  0      ' Important assumption for this code

   Type MungeLong
     X As Long
     Dummy As Integer
   End Type

   Type MungeInt
     XLo As Integer
     XHi As Integer
     Dummy As Integer
   End Type

   Type TUser0                    ' Level  0 
     ptrName As Long
   End Type

   Type TUser1                    ' Level 1
     ptrName As Long
     ptrPassword As Long
     dwPasswordAge As Long
     dwPriv As Long
     ptrHomeDir As Long
     ptrComment As Long
     dwFlags As Long
     ptrScriptPath As Long
   End Type

   '
   ' for dwPriv
   '
   Const USER_PRIV_MASK = &H3
   Const USER_PRIV_GUEST = &H0
   Const USER_PRIV_USER = &H1
   Const USER_PRIV_ADMIN = &H2

   '
   ' for dwFlags
   '
   Const UF_SCRIPT = &H1
   Const UF_ACCOUNTDISABLE = &H2
   Const UF_HOMEDIR_REQUIRED = &H8
   Const UF_LOCKOUT = &H10
   Const UF_PASSWD_NOTREQD = &H20
   Const UF_PASSWD_CANT_CHANGE = &H40
   Const UF_NORMAL_ACCOUNT = &H200     ' Needs to be ORed with the
                                       ' other flags

   '
   ' for lFilter
   '
   Const FILTER_NORMAL_ACCOUNT = &H2

   Declare Function NetGetDCName Lib  "NETAPI32.DLL"  (ServerName As Byte, _
   DomainName As Byte, DCNPtr As Long) As Long

   Declare Function NetUserDel Lib  "NETAPI32.DLL"  (ServerName As Byte, _
   UserName As Byte) As Long

   Declare Function NetGroupAddUser Lib  "NETAPI32.DLL"  (ServerName As _
   Byte, GroupName As Byte, UserName As Byte) As Long

   Declare Function NetGroupDelUser Lib  "NETAPI32.DLL"  (ServerName As _
   Byte, GroupName As Byte, UserName As Byte) As Long

   ' Add using Level 1 user structure
   Declare Function NetUserAdd1 Lib "NETAPI32.DLL" Alias "NetUserAdd" _
   (ServerName As Byte, ByVal Level As Long, Buffer As TUser1, ParmError _
   As Long) As Long

   ' Enumerate using Level  0  user structure
   Declare Function NetUserEnum0 Lib  "NETAPI32.DLL"  Alias  "NetUserEnum"  _
   (ServerName As Byte, ByVal Level As Long, ByVal lFilter As Long, _
   Buffer As Long, ByVal PrefMaxLen As Long, EntriesRead As Long, _
   TotalEntries As Long, ResumeHandle As Long) As Long

   Declare Function NetGroupEnumUsers0 Lib  "NETAPI32.DLL"  Alias _
    "NetGroupGetUsers"  (ServerName As Byte, GroupName As Byte, _
   ByVal Level As Long, Buffer As Long, ByVal PrefMaxLen As Long, _
   EntriesRead As Long, TotalEntries As Long, ResumeHandle As Long) As Long

   Declare Function NetGroupEnum0 Lib  "NETAPI32.DLL"  Alias  "NetGroupEnum"  _
   (ServerName As Byte, ByVal Level As Long, Buffer As Long, ByVal _
   PrefMaxLen As Long, EntriesRead As Long, TotalEntries As Long, _
   ResumeHandle As Long) As Long

   Declare Function NetUserGetGroups0 Lib  "NETAPI32.DLL"  Alias _
    "NetUserGetGroups"  (ServerName As Byte, UserName As Byte, _
   ByVal Level As Long, Buffer As Long, ByVal PrefMaxLen As Long, _
   EntriesRead As Long, TotalEntries As Long) As Long

   Declare Function NetAPIBufferFree Lib  "NETAPI32.DLL"  Alias _
    "NetApiBufferFree"  (ByVal Ptr As Long) As Long

   Declare Function NetAPIBufferAllocate Lib  "NETAPI32.DLL"  Alias _
    "NetApiBufferAllocate"  (ByVal ByteCount As Long, Ptr As Long) As Long

   Declare Function PtrToStr Lib  "Kernel32"  Alias  "lstrcpyW"  _
   (RetVal As Byte, ByVal Ptr As Long) As Long

   Declare Function StrToPtr Lib  "Kernel32"  Alias  "lstrcpyW"  _
   (ByVal Ptr As Long, Source As Byte) As Long

   Declare Function PtrToInt Lib  "Kernel32"  Alias  "lstrcpynW"  _
   (RetVal As Any, ByVal Ptr As Long, ByVal nCharCount As Long) As Long

   Declare Function StrLen Lib  "Kernel32"  Alias  "lstrlenW"  _
   (ByVal Ptr As Long) As Long

   Function AddUserToGroup(ByVal SName As String, _
   ByVal GName As String, ByVal UName As String) As Long
   '
   ' This only adds users to global groups - not to local groups
   '
   Dim SNArray() As Byte, GNArray() As Byte, UNArray() As Byte, _
   Result As Long
     SNArray = SName & vbNullChar
     GNArray = GName & vbNullChar
     UNArray = UName & vbNullChar
     Result = NetGroupAddUser(SNArray(0), GNArray(0), UNArray(0))
     If Result = 2220 Then Debug.Print _
   "There is no **GLOBAL** group ' " & GName & " '"
     AddUserToGroup = Result
   End Function

   Function DelUser(ByVal SName As String, ByVal UName As String) As Long
   Dim UNArray() As Byte, SNArray() As Byte
     UNArray = UName & vbNullChar
     SNArray = SName & vbNullChar
     DelUser = NetUserDel(SNArray(0), UNArray(0))
   End Function

   Function DelUserFromGroup(ByVal SName As String, _
   ByVal GName As String, ByVal UName As String) As Long
   '
   ' This only deletes users from global groups - not local groups
   '
   Dim SNArray() As Byte, GNArray() As Byte, UNArray() As Byte, _
   Result As Long
     SNArray = SName & vbNullChar
     GNArray = GName & vbNullChar
     UNArray = UName & vbNullChar
     Result = NetGroupDelUser(SNArray( 0 ), GNArray( 0 ), UNArray( 0 ))
     If Result =  2220  Then Debug.Print _
    "There is no **GLOBAL** group '" & GName & "'" 
     DelUserFromGroup = Result
   End Function

   Function EnumerateGroups(ByVal SName As String, _
   ByVal UName As String) As Long
   '
   ' Enumerates global groups only - not local groups
   '
   ' The buffer is filled from the left with pointers to user names that
   ' are filled from the right side. For example:
   '
   '     ptr1|ptr2|...|ptrn|<garbage>|strn|...|str2|str1
   '     ^ -------------- BufPtr buffer ----------------^
 
   '
   ' On NT, TotalEntries is the number of entries left to be read including
   ' the currently read entries.
   '
   ' On LanMan and OS/2, it is the total number of entries, period. Code
   ' would have to be changed to reflect this if the Domain controller
   ' wasn't an NT machine.
   '
   ' BufPtr gets the address of the buffer (or ptr1 - add  4  to BufPtr for
   ' each additional pointer)
   '
   Dim Result As Long, BufPtr As Long, EntriesRead As Long, _
   TotalEntries As Long, ResumeHandle As Long, BufLen As Long, _
   SNArray() As Byte, GNArray( 99 ) As Byte, UNArray() As Byte, _
   GName As String, I As Integer, UNPtr As Long, _
   TempPtr As MungeLong, TempStr As MungeInt

     SNArray = SName & vbNullChar       ' Move to byte array
     UNArray = UName & vbNullChar       ' Move to Byte array
     BufLen =  255                        ' Buffer size
     ResumeHandle = 0                   ' Start with the first entry

     Do
       If UName =  "" Then
         Result = NetGroupEnum0(SNArray(0 ),  0 , BufPtr, BufLen, _
   EntriesRead, TotalEntries, ResumeHandle)
       Else
         Result = NetUserGetGroups0(SNArray( 0 ), UNArray( 0 ),  0 , BufPtr, _
   BufLen, EntriesRead, TotalEntries)
       End If
       EnumerateGroups = Result
       If Result <>  0  And Result <>  234  Then    ' 234 means multiple reads
                                                ' required
         Debug.Print "Error  " & Result & "  enumerating group  " & _
   EntriesRead & "  of  " & TotalEntries
         Exit Function
       End If
       For I = 1  To EntriesRead
         ' Get pointer to string from beginning of buffer
         ' Copy  4  byte block of memory in  2  steps
         Result = PtrToInt(TempStr.XLo, BufPtr + (I -  1 ) *  4 ,  2 )
         Result = PtrToInt(TempStr.XHi, BufPtr + (I -  1 ) *  4  +  2 ,  2 )
         LSet TempPtr = TempStr ' munge 2 Integers to a Long
         ' Copy string to array and convert to a string
         Result = PtrToStr(GNArray( 0 ), TempPtr.X)
         GName = Left(GNArray, StrLen(TempPtr.X))
         Debug.Print "Group:  " & GName
       Next I
     Loop Until EntriesRead = TotalEntries
   ' The above condition only valid for reading accounts on NT
   ' but not OK for OS/2  or LanMan

     Result = NetAPIBufferFree(BufPtr)         ' Don't leak memory

   End Function

   Function EnumerateUsers(ByVal SName As String, ByVal GName As String) _
   As Long
   '
   ' If a group name is specified, it must be a global group
   ' and not a local group.
   '
   ' The buffer is filled from the left with pointers to user names that
   ' are filled from the right side. For example:
   '
   '     ptr1|ptr2|...|ptrn|<garbage>|strn|...|str2|str1
   '     ^-------------- BufPtr buffer ----------------^
   '
   ' On Windows NT, TotalEntries is the number of entries left to be read,
   ' including the currently read entries.
   ' On LanMan and OS/2, it is the total number of entries, period.  Code
   ' would have to be changed to reflect this if the Domain controller
   ' wasn't an NT machine.
   '
   ' BufPtr gets the address of the buffer (or ptr1 - add  4  to BufPtr for
   ' each additional pointer)
   '
   ' SName should be "\\servername"
   '
   Dim Result As Long, BufPtr As Long, EntriesRead As Long, _
   TotalEntries As Long, ResumeHandle As Long, BufLen As Long, _
   SNArray() As Byte, GNArray() As Byte, UNArray( 99 ) As Byte, _
   UName As String, I As Integer, UNPtr As Long, TempPtr As MungeLong, _
   TempStr As MungeInt

     SNArray = SName & vbNullChar       ' Move to byte array
     GNArray = GName & vbNullChar       ' Move to Byte array
     BufLen =  255                        ' Buffer size
     ResumeHandle = 0                   ' Start with the first entry

     Do
       If GName = " " Then
         Result = NetUserEnum0(SNArray(0 ),  0 , FILTER_NORMAL_ACCOUNT, _
   BufPtr, BufLen, EntriesRead, TotalEntries, ResumeHandle)
       Else
         Result = NetGroupEnumUsers0(SNArray( 0 ), GNArray( 0 ),  0 , BufPtr, _
   BufLen, EntriesRead, TotalEntries, ResumeHandle)
       End If
       EnumerateUsers = Result
       If Result <>  0  And Result <>  234  Then    ' 234 means multiple reads
                                                ' required
         Debug.Print "Error  " & Result & "  enumerating user  " _
   & EntriesRead & "  of  " & TotalEntries
         If Result = 2220  Then Debug.Print _
   "There is no **GLOBAL** group '" & GName & "' "
         Exit Function
       End If
       For I = 1  To EntriesRead
         ' Get pointer to string from beginning of buffer
         ' Copy  4 -byte block of memory in  2  steps
         Result = PtrToInt(TempStr.XLo, BufPtr + (I -  1 ) *  4 ,  2 )
         Result = PtrToInt(TempStr.XHi, BufPtr + (I -  1 ) *  4  +  2 ,  2 )
         LSet TempPtr = TempStr ' munge 2 integers into a Long
         ' Copy string to array
         Result = PtrToStr(UNArray( 0 ), TempPtr.X)
         UName = Left(UNArray, StrLen(TempPtr.X))
         Debug.Print "User:  " & UName
       Next I
     Loop Until EntriesRead = TotalEntries
   ' The above condition is only valid for reading accounts on Windows NT,
   ' but is not OK for OS/2  or LanMan

     Result = NetAPIBufferFree(BufPtr)         ' Don't leak memory

   End Function

   Function GetPrimaryDCName(ByVal MName As String, _
   ByVal DName As String) As String
   Dim Result As Long, DCName As String, DCNPtr As Long
   Dim DNArray() As Byte, MNArray() As Byte, DCNArray( 100 ) As Byte
     MNArray = MName & vbNullChar
     DNArray = DName & vbNullChar
     Result = NetGetDCName(MNArray( 0 ), DNArray( 0 ), DCNPtr)
     If Result <>  0  Then
       Debug.Print "Error: " & Result
       Exit Function
     End If
     Result = PtrToStr(DCNArray( 0 ), DCNPtr)
     Result = NetAPIBufferFree(DCNPtr)
     DCName = DCNArray()
     GetPrimaryDCName = DCName
   End Function

   Function AddUser(ByVal SName As String, ByVal UName As String, _
   ByVal PWD As String) As Long
   Dim Result As Long, UNPtr As Long, PWDPtr As Long, ParmError As Long
   Dim SNArray() As Byte, UNArray() As Byte, PWDArray() As Byte
   Dim UserStruct As TUser1
   '
   ' Move to byte arrays
   '
     SNArray = SName & vbNullChar
     UNArray = UName & vbNullChar
     PWDArray = PWD & vbNullChar
   '
   ' Allocate buffer space
   '
     Result = NetAPIBufferAllocate(UBound(UNArray) +  1 , UNPtr)
     Result = NetAPIBufferAllocate(UBound(PWDArray) +  1 , PWDPtr)
   '
   ' Copy arrays to the buffer
   '
     Result = StrToPtr(UNPtr, UNArray(0))
     Result = StrToPtr(PWDPtr, PWDArray(0))
   '
   ' Fill the structure
   '
     With UserStruct
       .ptrName = UNPtr
       .ptrPassword = PWDPtr
       .dwPasswordAge =  3 
       .dwPriv = USER_PRIV_USER
       .ptrHomeDir =  0 
       .ptrComment =  0 
       .dwFlags = UF_NORMAL_ACCOUNT Or UF_SCRIPT
       .ptrScriptPath =  0 
     End With
   '
   ' Add the user
   '
     Result = NetUserAdd1(SNArray(0), 1, UserStruct, ParmError)
     AddUser = Result
     If Result <> 0 Then
       Debug.Print "Error " & Result & " in parameter " & ParmError _
   & " when adding user " & UName
     End If
   '
   ' Release buffers from memory
   '
     Result = NetAPIBufferFree(UNPtr)
     Result = NetAPIBufferFree(PWDPtr)

   End Function
...
Рейтинг: 0 / 0
9 сообщений из 9, страница 1 из 1
Форумы / Microsoft Access [игнор отключен] [закрыт для гостей] / Список компьютеров и пользователей в сети
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]