might take a bit of tweaking, but a simple solution might be this vbs 
code...

Set WshShell = CreateObject("WScript.Shell")
Set rootDSE = GetObject("LDAP://RootDSE")
domainContainer =  rootDSE.Get("defaultNamingContext")
Set conn = CreateObject("ADODB.Connection")
conn.Provider = "ADSDSOObject"
conn.Open "ADs Provider"
Const ADS_UF_ACCOUNTDISABLE = 2
' location of userlist
TheFilePath="c:\file.txt"
set objFS=CreateObject("Scripting.FileSystemObject")
set FileObj = objFS.OpenTextFile(ThefilePath,1,false)
Do Until FileObj.AtEndOfStream
        struser = FileObj.Readline
        LDAPStr = "<LDAP://" & DomainContainer &  ">; _
        (&(objectClass=User)(objectCategory=Person)(anr=" & struser & "))" 
& _
        ";distinguishedName;subtree"
        'msgbox LDAPStr
        set rs = conn.Execute(LDAPStr)
        If rs.RecordCount > 0 Then
        rs.MoveFirst
        do until rs.EOF
                Set objUser = GetObject ("LDAP://" & 
rs.fields("distinguishedName"))
                intUAC = objUser.Get("userAccountControl")
'disable the account
                objUser.Put "userAccountControl", intUAC OR 
ADS_UF_ACCOUNTDISABLE
                objUser.SetInfo
' change the OU info here to move the account
                Set objOU = 
GetObject("LDAP://ou=sales,dc=na,dc=fabrikam,dc=com")
                objOU.MoveHere _
                    "LDAP://" & rs.fields("distinguishedName"), 
vbNullString
        rs.movenext
        loop
        end if
loop
FileObj.close
conn.close
msgbox "done"


Doug





"Ramon Linan" <[EMAIL PROTECTED]> 
Sent by: <[EMAIL PROTECTED]>
08/25/2006 02:16 PM
Please respond to
<[email protected]>


To
<[email protected]>
cc

Subject
[ActiveDir] disable 200 users






Hi,
 
I have been given a list of 200 users to disable, and move to another OU.
The users are not currently in the same OU but in many different OU.
 
I am trying to use the txt file that contains the list of users to be 
disable.
 
How can I do this?
 
 
I was trying to use the query tool that comes with AD users and computer 
to select the users but got nowhere with
 
(&(&(&(|(&(objectCategory=person)(objectSid=*)(!samAccountType:1.2.840.113556.1.4.804:=3))(&(objectCategory=person)(!objectSid=*))(&(objectCategory=group)(groupType:1.2.840.113556.1.4.804:=14))))(objectCategory=user)(cn=user1)))
(&(&(&(|(&(objectCategory=person)(objectSid=*)(!samAccountType:1.2.840.113556.1.4.804:=3))(&(objectCategory=person)(!objectSid=*))(&(objectCategory=group)(groupType:1.2.840.113556.1.4.804:=14))))(objectCategory=user)(cn=user2)))
etc
 
 
Thanks
Rezuma 

Reply via email to