<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS: Блокировка пользователя в Домене]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=5150&amp;type=atom" />
	<updated>2010-11-24T14:23:44Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=5150</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Блокировка пользователя в Домене]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42148#p42148" />
			<content type="html"><![CDATA[<p>OFF: Я всем рекомендую загружать локальную базу (<a href="http://forum.script-coding.com/viewtopic.php?id=2419">OFF: MSDN по-русски</a> — если уже нет более свежей), весьма помогает.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2010-11-24T14:23:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42148#p42148</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Блокировка пользователя в Домене]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42140#p42140" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>afteroot пишет:</cite><blockquote><p>... откуда Инфу берёте...</p></blockquote></div><p>1. Полнее, чем MSDN, источника не существует.<br />2. <strong>alexii</strong> уже указал Вам на коллекцию ссылок, выбирайте оттуда, что требуется. Ссылка на MSDN, например,- самая первая в первом же сообщении этой коллекции.</p>]]></content>
			<author>
				<name><![CDATA[Dmitrii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=13351</uri>
			</author>
			<updated>2010-11-24T11:41:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42140#p42140</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Блокировка пользователя в Домене]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42137#p42137" />
			<content type="html"><![CDATA[<p>Дмитрий ОГРОМНОЕ СПАСИБО! Выручили!<br />Если не секрет откуда Инфу берёте или книги какие лучше почитать? За рание спасибо!</p>]]></content>
			<author>
				<name><![CDATA[afteroot]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25967</uri>
			</author>
			<updated>2010-11-24T09:54:09Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42137#p42137</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Блокировка пользователя в Домене]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42136#p42136" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>afteroot пишет:</cite><blockquote><p>... возникла необходимость Блокировка не через Логин, а через displayName. Случаем не подскажите уважаемые как еще и такое можно организовать?</p></blockquote></div><p>Либо с помощью <strong><span style="color: blue">ADO</span></strong> (подобно ранее приведённому Вами примеру), либо с помощью интерфейса <strong><span style="color: blue">IADsNameTranslate</span></strong> найти &quot;учётку&quot; в AD, выполнить привязку и, наконец, отключить.<br />Пример с <strong>ADO</strong>:<br /></p><div class="codebox"><pre><code>Dim objRoot, strDomain
Dim objUser, strDisplayName, strTemp
Dim objConnection, objCommand, objRSet, strCommandText
Const ADS_SCOPE_SUBTREE = 2

Set objRoot = GetObject(&quot;LDAP://RootDSE&quot;)
strDomain = objRoot.Get(&quot;DefaultNamingContext&quot;)
Set objRoot = Nothing
strDisplayName = Trim(InputBox(&quot;Выводимое имя пользователя:&quot;))
If Len(strDisplayName) &gt; 0 Then
    Set objConnection = CreateObject(&quot;ADODB.Connection&quot;)
    objConnection.Provider = &quot;ADsDSOObject&quot;
    objConnection.Open &quot;Active Directory Provider&quot;
    Set objCommand = CreateObject(&quot;ADODB.Command&quot;)
    Set objCommand.ActiveConnection = objConnection
    strCommandText = &quot;SELECT ADsPath FROM &#039;LDAP://&quot; &amp; strDomain &amp; _
        &quot;&#039; WHERE objectCategory=&#039;Person&#039; AND objectClass=&#039;User&#039; AND displayName=&#039;&quot; &amp; strDisplayName &amp; &quot;&#039;&quot;
    objCommand.CommandText = strCommandText
    objCommand.Properties(&quot;Page Size&quot;) = 1000
    objCommand.Properties(&quot;Timeout&quot;) = 30
    objCommand.Properties(&quot;Searchscope&quot;) = ADS_SCOPE_SUBTREE
    Set objRSet = objCommand.Execute
    If objRSet.RecordCount = 1 Then
        objRSet.MoveFirst
        strTemp = objRSet.Fields(&quot;ADsPath&quot;).Value
        On Error Resume Next
        Set objUser = GetObject(strTemp)
        If Err.Number = 0 Then
            objUser.AccountDisabled = True
            objUser.SetInfo
            If Err.Number = 0 Then
                strTemp = &quot;Учётная запись отключена.&quot;
            Else
                strTemp = &quot;Ошибка отключения учётной записи: &quot; &amp; Err.Number
                Err.Clear
            End If
        Else
            strTemp = &quot;Ошибка привязки к найденному объекту: &quot; &amp; Err.Number
            Err.Clear
        End If
        Set objUser = Nothing
    Else
        strTemp = &quot;Учётная запись пользователя &quot; &amp; UCase(strDisplayName) &amp; &quot; не обнаружена.&quot;
    End If
    Set objRSet = Nothing
    Set objCommand = Nothing
    objConnection.Close
    Set objConnection = Nothing
    WScript.Echo strTemp
End If
WScript.Quit 0</code></pre></div><p>Пример с <strong>IADsNameTranslate</strong>:<br /></p><div class="codebox"><pre><code>Dim objWSNet, strDomain
Dim objTranslate, objUser, strDisplayName, strTemp
Const ADS_NAME_INITTYPE_DOMAIN = 1
Const ADS_NAME_TYPE_DISPLAY = 4
Const ADS_NAME_TYPE_1779 = 1

strDisplayName = Trim(InputBox(&quot;Выводимое имя пользователя:&quot;))
If Len(strDisplayName) &gt; 0 Then
    Set objWSNet = CreateObject(&quot;WScript.Network&quot;)
    strDomain = objWSNet.UserDomain
    Set objWSNet = Nothing
    On Error Resume Next
    Set objTranslate = CreateObject(&quot;NameTranslate&quot;)
    If Err.Number = 0 Then
        objTranslate.Init ADS_NAME_INITTYPE_DOMAIN, strDomain
        If Err.Number = 0 Then
            objTranslate.Set ADS_NAME_TYPE_DISPLAY, strDisplayName
            If Err.Number = 0 Then
                Set objUser = GetObject(&quot;LDAP://&quot; &amp; objTranslate.Get(ADS_NAME_TYPE_1779))
                If Err.Number = 0 Then
                    objUser.AccountDisabled = True
                    objUser.SetInfo
                    If Err.Number = 0 Then
                        strTemp = &quot;Учётная запись отключена.&quot;
                    Else
                        strTemp = &quot;Ошибка отключения учётной записи: &quot; &amp; Err.Number
                        Err.Clear
                    End If
                    Set objUser = Nothing
                Else
                    strTemp = &quot;Ошибка привязки к найденному объекту: &quot; &amp; Err.Number
                    Err.Clear
                End If
            Else
                strTemp = &quot;Ошибка транслирования: &quot; &amp; Err.Number
                Err.Clear
            End If
        Else
            strTemp = &quot;Ошибка привязки к источнику транслирования: &quot; &amp; Err.Number
            Err.Clear
        End If
        Set objTranslate = Nothing
    Else
        strTemp = &quot;Ошибка создания объекта &quot;&quot;NameTranslate&quot;&quot;: &quot; &amp; Err.Number
        Err.Clear
    End If
    WScript.Echo strTemp
End If
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>2010-11-24T09:43:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42136#p42136</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Блокировка пользователя в Домене]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42114#p42114" />
			<content type="html"><![CDATA[<p><span style="color: Green"><strong>afteroot</strong>, коллега, либо Вы наконец начнёте применять <a href="http://forum.script-coding.com/help.php#bbcode">тэги</a> на регулярной основе (я <a href="http://forum.script-coding.com/viewtopic.php?pid=42101#p42101">оформил Ваш пост</a>), либо… будет последнее китайское предупреждение <img src="//forum.script-coding.com/img/smilies/lol.png" width="15" height="15" />.</span></p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2010-11-23T17:49:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42114#p42114</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Блокировка пользователя в Домене]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42103#p42103" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Так ведь уже есть готовый пример: <a href="http://forum.script-coding.com/viewtopic.php?pid=19948#p19948">здесь</a>. Что в нём не устраивает?</p></blockquote></div><p>Сорри уже все нормально! Решил проблему, просто меня смущало что через Имя компа оно искало, подставил домен, и все заработало <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br />Только вот теперь возникла необходимость Блокировка не через Логин, а через displayName. Случаем не подскажите уважаемые как еще и такое можно организовать?</p>]]></content>
			<author>
				<name><![CDATA[afteroot]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25967</uri>
			</author>
			<updated>2010-11-23T14:40:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42103#p42103</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Блокировка пользователя в Домене]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42102#p42102" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>afteroot пишет:</cite><blockquote><p>Вот только единственная проблема с такой строчки! Нужны права Админа, как их тут ввести?</p></blockquote></div><p>Используйте <strong><span style="color: blue">runas</span></strong></p><div class="quotebox"><cite>afteroot пишет:</cite><blockquote><p>... нашел именно поиск самого пользователя в АД, находит показывает...</p></blockquote></div><p>Зачем его искать-то, если Вам уже известно имя &quot;учётки&quot;? Если есть сомнения в том, верно ли указано имя, то можно просто &quot;ловить&quot; ошибку подключения. Например:<br /></p><div class="codebox"><pre><code>On Error Resume Next
Set objUser = GetObject(&quot;WinNT://&quot; &amp; strComputerName &amp; &quot;/&quot; &amp; strUserName &amp; &quot;,user&quot;)
If Err.Number = 0 Then
    objUser.AccountDisabled = True
    objUser.SetInfo
Else
    Err.Clear
End If
On Error GoTo 0</code></pre></div><div class="quotebox"><cite>afteroot пишет:</cite><blockquote><p>... как теперь его заблокировать?</p></blockquote></div><p>Так ведь уже есть готовый пример: <a href="http://forum.script-coding.com/viewtopic.php?pid=19948#p19948">здесь</a>. Что в нём не устраивает?</p>]]></content>
			<author>
				<name><![CDATA[Dmitrii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=13351</uri>
			</author>
			<updated>2010-11-23T14:16:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42102#p42102</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Блокировка пользователя в Домене]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42101#p42101" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>domainname=inputbox(&quot;Enter DNS Domain Name&quot; &amp; vbcrlf &amp; &quot;(Leave blank for current domain):&quot;)
username=inputbox(&quot;Enter username:&quot;)


if domainname = &quot;&quot; then
    set objRoot = getobject(&quot;LDAP://RootDSE&quot;)
    domainname = objRoot.get(&quot;defaultNamingContext&quot;)
end if

if username &lt;&gt; &quot;&quot; then

    wscript.echo finduser(username,domainname)
    
end if


Function FindUser(Byval UserName, Byval Domain) 
    on error resume next

    set cn = createobject(&quot;ADODB.Connection&quot;)
    set cmd = createobject(&quot;ADODB.Command&quot;)
    set rs = createobject(&quot;ADODB.Recordset&quot;)

    cn.open &quot;Provider=ADsDSOObject;&quot;
    
    cmd.activeconnection=cn
    cmd.commandtext=&quot;SELECT ADsPath FROM &#039;LDAP://&quot; &amp; Domain &amp; &quot;&#039; WHERE sAMAccountName = &#039;&quot; &amp; UserName &amp; &quot;&#039;&quot;
    
    set rs = cmd.execute


    if err&lt;&gt;0 then
        FindUser=&quot;Error connecting to Active Directory Database:&quot; &amp; err.description
    else
        if not rs.BOF and not rs.EOF then
                 rs.MoveFirst
                 FindUser = rs(0)

        else
            FindUser = &quot;Not Found&quot;
        end if
    end if
    cn.close
end function</code></pre></div><p>Вот нашел именно поиск самого пользователя в АД, находит показывает, а как теперь его заблокировать? Сделать Disable Account?</p>]]></content>
			<author>
				<name><![CDATA[afteroot]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25967</uri>
			</author>
			<updated>2010-11-23T13:08:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42101#p42101</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Блокировка пользователя в Домене]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42093#p42093" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>VitAliS пишет:</cite><blockquote><p>не знаю зачем люди городят леса такие<br />в cmd всё сводится к одной строке:<br /></p><div class="codebox"><pre><code>net user &lt;название учетки&gt; /domain /active:no</code></pre></div></blockquote></div><p>Вот только единственная проблема с такой строчки! Нужны права Админа, как их тут ввести?</p>]]></content>
			<author>
				<name><![CDATA[afteroot]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25967</uri>
			</author>
			<updated>2010-11-23T07:43:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42093#p42093</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Блокировка пользователя в Домене]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=41524#p41524" />
			<content type="html"><![CDATA[<p>не знаю зачем люди городят леса такие<br />в cmd всё сводится к одной строке:<br /></p><div class="codebox"><pre><code>net user &lt;название учетки&gt; /domain /active:no</code></pre></div>]]></content>
			<author>
				<name><![CDATA[VitAliS]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24943</uri>
			</author>
			<updated>2010-11-12T07:04:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=41524#p41524</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Блокировка пользователя в Домене]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=41501#p41501" />
			<content type="html"><![CDATA[<p><span style="color: Green"><strong>afteroot</strong>, избегайте <a href="http://forum.script-coding.com/viewtopic.php?pid=41495#p41495">излишнего</a> цитирования.</span></p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2010-11-11T13:21:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=41501#p41501</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Блокировка пользователя в Домене]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=41497#p41497" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>afteroot пишет:</cite><blockquote><p>Нет не встроенной, объект AD</p></blockquote></div><p>Тогда действуйте, как я Вам уже посоветовал.</p>]]></content>
			<author>
				<name><![CDATA[Dmitrii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=13351</uri>
			</author>
			<updated>2010-11-11T12:39:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=41497#p41497</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Блокировка пользователя в Домене]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=41495#p41495" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Dmitrii пишет:</cite><blockquote><div class="quotebox"><cite>afteroot пишет:</cite><blockquote><p>... но в домене можно же на любой комп зайти под любой учеткой , значит мне нужно отключить учетку в АД, и не на локальном компьютере а что б ей никто не мог пользоваться!</p></blockquote></div><p>В рассматриваемом случае обращение к &quot;учётке&quot; на контроллере и есть обращение к объекту AD. Или Вы хотите управлять встроенной &quot;учёткой&quot; администратора?</p><p>Нет не встроенной, объект AD!</p><div class="quotebox"><cite>Dmitrii пишет:</cite><blockquote><p>... надо указать NetBIOS-имя любого контроллера домена.</p></blockquote></div><p>Поправка: если контроллеры - на платформе Win 2008, то (в данной задаче) <span style="color: red"><strong>не годятся</strong> контроллеры, исполняющие роль <strong>RODC</strong></span> (Read Only DC), т.к. не позволяют вносить изменения в AD.</p></blockquote></div><p>платформа Win 2003</p>]]></content>
			<author>
				<name><![CDATA[afteroot]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25967</uri>
			</author>
			<updated>2010-11-11T11:46:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=41495#p41495</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Блокировка пользователя в Домене]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=41493#p41493" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>afteroot пишет:</cite><blockquote><p>... но в домене можно же на любой комп зайти под любой учеткой , значит мне нужно отключить учетку в АД, и не на локальном компьютере а что б ей никто не мог пользоваться!</p></blockquote></div><p>В рассматриваемом случае обращение к &quot;учётке&quot; на контроллере и есть обращение к объекту AD. Или Вы хотите управлять встроенной &quot;учёткой&quot; администратора?</p><div class="quotebox"><cite>Dmitrii пишет:</cite><blockquote><p>... надо указать NetBIOS-имя любого контроллера домена.</p></blockquote></div><p>Поправка: если контроллеры - на платформе Win 2008, то (в данной задаче) <span style="color: red"><strong>не годятся</strong> контроллеры, исполняющие роль <strong>RODC</strong></span> (Read Only DC), т.к. не позволяют вносить изменения в AD.</p>]]></content>
			<author>
				<name><![CDATA[Dmitrii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=13351</uri>
			</author>
			<updated>2010-11-11T11:37:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=41493#p41493</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Блокировка пользователя в Домене]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=41487#p41487" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Dmitrii пишет:</cite><blockquote><div class="quotebox"><cite>afteroot пишет:</cite><blockquote><p>... как просто Блокировать пользователя в АД...</p></blockquote></div><p>Не оставляет меня мысль, что на самом деле Вы хотите не блокировать, а отключить &quot;учётку&quot; (это не одно и то же). Если речь именно об отключении, то в <a href="http://forum.script-coding.com/viewtopic.php?pid=19948#p19948">сообщении #5</a> темы &quot;VBS, блокирование учетной записи пользователя на локальном компьютере&quot; уже имеется соответствующий пример.<br />Адаптация его к использованию в домене минимальна - в качестве значения переменной <strong><span style="color: blue">strComputerName</span></strong> надо указать NetBIOS-имя любого контроллера домена.</p></blockquote></div><p>Эм.. но в домене можно же на любой комп зайти под любой учеткой , значит мне нужно отключить учетку в АД, и не на локальном компьютере а что б ей никто не мог пользоваться!</p>]]></content>
			<author>
				<name><![CDATA[afteroot]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25967</uri>
			</author>
			<updated>2010-11-11T06:33:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=41487#p41487</id>
		</entry>
</feed>
