<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS: получить список только активных учетных записей из AD.]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=3217&amp;type=atom" />
	<updated>2010-11-17T07:09:20Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=3217</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS: получить список только активных учетных записей из AD.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=41803#p41803" />
			<content type="html"><![CDATA[<p><a href="http://eddnet.org/?p=799">вот</a> хороший пример.</p>]]></content>
			<author>
				<name><![CDATA[Wiliam]]></name>
			</author>
			<updated>2010-11-17T07:09:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=41803#p41803</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: получить список только активных учетных записей из AD.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=24000#p24000" />
			<content type="html"><![CDATA[<p>Как то так что ли:<br /></p><div class="codebox"><pre><code>Dim objFSO, objGroup, objItem, Text
Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Const strGroup = &quot;Domain Computers&quot;
Set objGroup = GetObject(&quot;WinNT://domain/&quot; &amp; strGroup &amp; &quot;,group&quot;)
Set Text = objFSO.CreateTextFile (&quot;с:\report.xls&quot;, True)
Text.Write &quot;Дата выгрузки: &quot; &amp; Date() &amp; &quot;. &quot; &amp; &quot;Учетные записи ПК, которые незаблокированны:&quot; &amp; VbNullString
For Each objItem In objGroup.Members
If Not objItem.AccountDisabled Then
Text.WriteLine &quot;&quot; &amp; objItem.Name
End If
Next</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Oberschlesien]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24830</uri>
			</author>
			<updated>2009-05-31T05:18:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=24000#p24000</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: получить список только активных учетных записей из AD.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=23808#p23808" />
			<content type="html"><![CDATA[<p><strong>Oberschlesien</strong>, попробуйте такой вариант:<br /></p><div class="codebox"><pre><code>Dim objWsNet, objGroup, objItem
Dim intCounter, strDomain, strList, strTemp
Const strGroup = &quot;Компьютеры домена&quot;
Set objWsNet = CreateObject(&quot;WScript.Network&quot;)
strDomain = objWsNet.UserDomain
Set objWsNet = Nothing
Set objGroup = GetObject(&quot;WinNT://&quot; &amp; strDomain &amp; &quot;/&quot; &amp; strGroup &amp; &quot;,group&quot;)
intCounter = 0: strList = vbNullString
For Each objItem In objGroup.Members
    If Not objItem.AccountDisabled Then
        intCounter = intCounter + 1
        &#039;strTemp = objItem.Name
        &#039;strList = strList &amp; intCounter &amp; &quot;. &quot; &amp; Left(strTemp, Len(strTemp) - 1) &amp; vbNewLine
    End If
Next
Set objItem = Nothing
Set objGroup = Nothing
WScript.Echo &quot;Всего включенных записей: &quot; &amp; intCounter &#039;&amp; vbNewLine &amp; &quot;===&quot; &amp; vbNewLine &amp; strList
WScript.Quit 0</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Dmitrii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=13351</uri>
			</author>
			<updated>2009-05-28T09:29:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=23808#p23808</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: получить список только активных учетных записей из AD.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=23791#p23791" />
			<content type="html"><![CDATA[<p>Посмотрим днём.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2009-05-28T01:04:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=23791#p23791</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: получить список только активных учетных записей из AD.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=23789#p23789" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>Option Explicit

Const ADS_UF_ACCOUNTDISABLE = &amp;H0002

Dim objIADsContainer
Dim objIADsComputer

Dim intCounter


Set objIADsContainer = GetObject(&quot;WinNT://domain&quot;)

objIADsContainer.Filter = Array(&quot;Computer&quot;)


intCounter = 0

WScript.Echo &quot;--------------------------------------------------&quot;

For Each objIADsComputer In objIADsContainer
    If Not objIADsComputer.AccountDisabled Then
        intCounter = intCounter + 1
        
        WScript.Echo intCounter &amp; &quot;. &quot; &amp; objIADsComputer.Name
    End If
Next

WScript.Echo &quot;--------------------------------------------------&quot;
WScript.Echo &quot;Total of &quot; &amp; intCounter &amp; &quot; accounts aren&#039;t disabled.&quot;


&#039; или
WScript.Echo

intCounter = 0

WScript.Echo &quot;--------------------------------------------------&quot;

For Each objIADsComputer In objIADsContainer
    If objIADsComputer.Get(&quot;UserFlags&quot;) And ADS_UF_ACCOUNTDISABLE Then
    Else
        intCounter = intCounter + 1
        
        WScript.Echo intCounter &amp; &quot;. &quot; &amp; objIADsComputer.Name
    End If
Next

WScript.Echo &quot;--------------------------------------------------&quot;
WScript.Echo &quot;Total of &quot; &amp; intCounter &amp; &quot; accounts aren&#039;t disabled.&quot;


Set objIADsContainer = Nothing

WScript.Quit 0</code></pre></div><p>Line 21, Column 5: Объект не поддерживает это свойство или метод &#039;AccountDisabled&#039;: 800A01B6</p><br /><p>Если не останавливать дебагинг, то начинает показывать имена машин.</p>]]></content>
			<author>
				<name><![CDATA[Oberschlesien]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24830</uri>
			</author>
			<updated>2009-05-27T23:22:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=23789#p23789</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: получить список только активных учетных записей из AD.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=23788#p23788" />
			<content type="html"><![CDATA[<p><strong>Oberschlesien</strong>, тогда не понял, отчего вариант <a href="http://forum.script-coding.com/viewtopic.php?pid=23770#p23770">#4</a> с правкой из <a href="http://forum.script-coding.com/viewtopic.php?pid=23773#p23773">#6</a> не подойдёт? Я даже проверял у себя — во всех четырёх вариантах запросов (по два на каждого из провайдеров, WinNT: и LDAP:) отработало одинаково. Я просто не стал приводить полных текстов (поскольку они, фактически, идентичны, за исключением правок из <a href="http://forum.script-coding.com/viewtopic.php?pid=23773#p23773">#6</a>). Как сие отрабатывает у Вас?</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2009-05-27T21:13:55Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=23788#p23788</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: получить список только активных учетных записей из AD.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=23784#p23784" />
			<content type="html"><![CDATA[<p>alexii, я правил это точно, а вот что - не помню, кажется, в первом варианте были указаны все типы учетных записей (далее и выше по тексту - УЗ).<br />OFF: Честно говоря, очень удивляет, что в Инете появились такие ребята как Вы. Я немного удивлен. Нет &quot;понтов&quot; и агрессии, уважают правописание, с интересом рассматривают любой вопрос, не умничают не по делу, модерят космонавтов, которые вместо ответа кидают 1234 ссылок и пишут типа &quot;вот тут почитай&quot;. Но форум, похоже, обречен стать попсовым.</p>]]></content>
			<author>
				<name><![CDATA[Oberschlesien]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24830</uri>
			</author>
			<updated>2009-05-27T18:16:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=23784#p23784</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: получить список только активных учетных записей из AD.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=23782#p23782" />
			<content type="html"><![CDATA[<p>OFF: <strong>2Oberschlesien</strong>: у Вас в первом посте изначально, с двух часов было прописано насчёт компьютеров? Или Вы потом кой-чего поправляли? Если верно первое, то я, похоже, не доглядел (меня смущает написанное «GetObject(&quot;WinNT://nwtraders1/AIvanov,user&quot;»). Потому я, с чистой совестью, и писал про работу с users.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2009-05-27T17:40:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=23782#p23782</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: получить список только активных учетных записей из AD.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=23781#p23781" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Oberschlesien пишет:</cite><blockquote><p>Не, не пойдет. Собственно, в этом и вся соль, что с УЗ компьютеров не получается.</p></blockquote></div><p>Расшифруйте для меня по-русски. Ничего не понял, что не пойдёт, а особенно насчёт «с УЗ компьютеров»?</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2009-05-27T17:33:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=23781#p23781</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: получить список только активных учетных записей из AD.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=23779#p23779" />
			<content type="html"><![CDATA[<p>Не, не пойдет. Собственно, в этом и вся соль, что с УЗ компьютеров не получается.<br />В первом посте темы так и было:<br />&quot;Необходимо получить список незаблокированных учетных записей компьютеров из AD.&quot;</p><p>Такой темы на форуме не было, может кому и помимо меня пригодиться.</p>]]></content>
			<author>
				<name><![CDATA[Oberschlesien]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24830</uri>
			</author>
			<updated>2009-05-27T15:48:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=23779#p23779</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: получить список только активных учетных записей из AD.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=23773#p23773" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>objIADsContainer.Filter = Array(&quot;Computer&quot;)</code></pre></div><p>для первого (ну, и можете вместо «objIADsUser» писать «objIADsComputer» для ясности, хотя все они светятся сквозь «головной» «IADs»), и:<br /></p><div class="codebox"><pre><code>    …
    &quot;(objectCategory=сomputer);…
    …</code></pre></div><p>для второго.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2009-05-27T15:22:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=23773#p23773</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: получить список только активных учетных записей из AD.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=23772#p23772" />
			<content type="html"><![CDATA[<p>А если речь идет об учетных записях компьютеров, а не пользователей?</p>]]></content>
			<author>
				<name><![CDATA[Oberschlesien]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24830</uri>
			</author>
			<updated>2009-05-27T15:10:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=23772#p23772</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: получить список только активных учетных записей из AD.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=23770#p23770" />
			<content type="html"><![CDATA[<p>Лучше рассчитывать на <strong>Dmitrii</strong>.<br /></p><div class="quotebox"><cite>Oberschlesien пишет:</cite><blockquote><p>Можно ли использовать провайдер WinNT,</p></blockquote></div><p>Можно:<br /></p><div class="codebox"><pre><code>Option Explicit

Const ADS_UF_ACCOUNTDISABLE = &amp;H0002

Dim objIADsContainer
Dim objIADsUser

Dim intCounter


Set objIADsContainer = GetObject(&quot;WinNT://DomainName,domain&quot;)

objIADsContainer.Filter = Array(&quot;User&quot;)


intCounter = 0

WScript.Echo &quot;--------------------------------------------------&quot;

For Each objIADsUser In objIADsContainer
    If Not objIADsUser.AccountDisabled Then
        intCounter = intCounter + 1
        
        WScript.Echo intCounter &amp; &quot;. &quot; &amp; objIADsUser.Name
    End If
Next

WScript.Echo &quot;--------------------------------------------------&quot;
WScript.Echo &quot;Total of &quot; &amp; intCounter &amp; &quot; accounts aren&#039;t disabled.&quot;


&#039; или
WScript.Echo

intCounter = 0

WScript.Echo &quot;--------------------------------------------------&quot;

For Each objIADsUser In objIADsContainer
    If objIADsUser.Get(&quot;UserFlags&quot;) And ADS_UF_ACCOUNTDISABLE Then
    Else
        intCounter = intCounter + 1
        
        WScript.Echo intCounter &amp; &quot;. &quot; &amp; objIADsUser.Name
    End If
Next

WScript.Echo &quot;--------------------------------------------------&quot;
WScript.Echo &quot;Total of &quot; &amp; intCounter &amp; &quot; accounts aren&#039;t disabled.&quot;


Set objIADsContainer = Nothing

WScript.Quit 0</code></pre></div><div class="quotebox"><cite>Oberschlesien пишет:</cite><blockquote><p>Еще интересен вариант через ADO.</p></blockquote></div><div class="codebox"><pre><code>Option Explicit

Const ADS_UF_ACCOUNTDISABLE = 2

Dim objConnection
Dim objCommand
Dim objRecordSet

Dim intUAC
Dim intCounter

Set objConnection = WScript.CreateObject(&quot;ADODB.Connection&quot;)
objConnection.Open &quot;Provider=ADsDSOObject;&quot;

Set objCommand = WScript.CreateObject(&quot;ADODB.Command&quot;)
objCommand.ActiveConnection = objConnection
objCommand.Properties(&quot;Sort on&quot;) = &quot;cn&quot;

objCommand.CommandText = _
    &quot;&lt;LDAP://dc=DomainName,dc=com&gt;;&quot; &amp; _
    &quot;(&amp;(objectClass=user)(objectCategory=person));&quot; &amp; _
    &quot;userAccountControl,distinguishedName;&quot; &amp; _
    &quot;subtree&quot;

Set objRecordSet = objCommand.Execute

intCounter = 0

With objRecordSet
    Do Until .EOF
        intUAC = .Fields(&quot;userAccountControl&quot;)
        
        If intUAC AND ADS_UF_ACCOUNTDISABLE Then
        Else
            intCounter = intCounter + 1
            
            WScript.Echo intCounter &amp; &quot;. &quot; &amp; .Fields(&quot;distinguishedName&quot;)
        End If
        
        .MoveNext
    Loop
    
    .Close
End With

WScript.Echo &quot;--------------------------------------------------&quot;
WScript.Echo &quot;Total of &quot; &amp; intCounter &amp; &quot; accounts aren&#039;t disabled.&quot;

&#039; или
WScript.Echo


objCommand.CommandText = _
    &quot;&lt;LDAP://dc=DomainName,dc=com&gt;;&quot; &amp; _
    &quot;(&amp;(objectClass=user)(objectCategory=person)(!(userAccountControl:1.2.840.113556.1.4.803:=2)));&quot; &amp; _
    &quot;userAccountControl,distinguishedName;&quot; &amp; _
    &quot;subtree&quot;

Set objRecordSet = objCommand.Execute

intCounter = 0

With objRecordSet
    Do Until .EOF
        intCounter = intCounter + 1
        WScript.Echo intCounter &amp; &quot;. &quot; &amp; .Fields(&quot;distinguishedName&quot;)
        
        .MoveNext
    Loop
    
    .Close
End With

WScript.Echo &quot;--------------------------------------------------&quot;
WScript.Echo &quot;Total of &quot; &amp; intCounter &amp; &quot; accounts aren&#039;t disabled.&quot;


objConnection.Close

Set objRecordSet  = Nothing
Set objCommand    = Nothing
Set objConnection = Nothing

WScript.Quit 0</code></pre></div>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2009-05-27T14:48:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=23770#p23770</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: получить список только активных учетных записей из AD.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=23758#p23758" />
			<content type="html"><![CDATA[<p>Еще интересен вариант через ADO.</p>]]></content>
			<author>
				<name><![CDATA[Oberschlesien]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24830</uri>
			</author>
			<updated>2009-05-27T10:15:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=23758#p23758</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBS: получить список только активных учетных записей из AD.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=23757#p23757" />
			<content type="html"><![CDATA[<p>Необходимо получить список незаблокированных учетных записей компьютеров из AD.<br />Я как то делал такой скрипт:</p><div class="codebox"><pre><code>Dim objGroup, objItem, objWsNet, objExcel

Set objWsNet = CreateObject(&quot;WScript.Network&quot;)
Set objGroup = GetObject(&quot;LDAP://CN=groupname,OU=OUname,DC=domainname,DC=com&quot;)
Set objExcel = CreateObject(&quot;Excel.Application&quot;)
objExcel.Visible = True
objExcel.Workbooks.Add
di = 1
For Each objItem In objGroup.Members
di = di + 1
objExcel.Cells(1, 2).Value = &quot;groupname:&quot;
objExcel.Cells(1, 2).Font.Bold = TRUE
objExcel.Cells(1, 2).Font.Size = 16
objExcel.Cells(di, 2).Value = objItem.Name
Next</code></pre></div><p>Скрипт открывает Excel и туда пишет членов определенного OU, указанного по LDAP (&quot;LDAP://CN=groupname,OU=OUname,DC=domainname,DC=com&quot;), но нужно чтобы он туда бросал только незаблокированные учетные записи компьютеров.<br />Можно ли использовать провайдер WinNT, чтобы выгружать всех УЗ компьютеров домена? (Ex: Set x = GetObject(&quot;WinNT://nwtraders1/AIvanov,user&quot;)).</p>]]></content>
			<author>
				<name><![CDATA[Oberschlesien]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24830</uri>
			</author>
			<updated>2009-05-27T10:09:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=23757#p23757</id>
		</entry>
</feed>
