WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Disable Computer Accounts

 Keywords: Disable Computer Account 

; You can disable a computer account in the same way you disable
; user account.

AddExtender("wwads44i.dll")

UF_ACCOUNTDISABLE  = 2                ; Account is disabled.
sComputerName      = "Test Computer" ; Relative name of computer to disable.

; Create the full DC path.
sServerDn=dsGetProperty("LDAP://shamrock/rootDSE", "defaultNamingContext")
sServerPath = StrCat("LDAP://shamrock/", sServerDn)

; Find the full computer object path
sFilter       = StrCat("(&(objectCategory=computer)(cn=", sComputerName, "))")
sComputerPath = dsFindPath(sServerPath, sFilter)


; Success?
If StrLen(sComputerPath) > 0

   ; Set the disabled bit in the userAccountControl property.
   nBits = dsGetProperty(sComputerPath, "userAccountControl")
   dsSetProperty(sComputerPath, "userAccountControl", nBits|UF_ACCOUNTDISABLE )

   Message("Computer Disabled", sComputerName)
Else
   Message("Unable to find computer", sComputerName)
EndIf


Article ID:   W16795
File Created: 2007:07:03:14:26:18
Last Updated: 2007:07:03:14:26:18