Results 1 to 4 of 4

Thread: Delete a computer from a domain

  1. #1
    Join Date
    Aug 2004
    Location
    Goa
    Posts
    38

    Delete a computer from a domain

    I am running Windows XP with SP2 and it's already being added on a domain now i want to remove it from the domain which i had added it in other words the computer is not currently attached to the domain/network it's apart of so I can not remove it from the domain controller end. Can anyone help me out with this issue ?

  2. #2
    Join Date
    Jan 2009
    Posts
    91

    Remove a computer from a domain

    If you really want to remove a computer from a domain then you need to right click on My computer then go to computer name tab over there you will find enter in a computer name that you want your computer click over it and then choose the Work Group option at the bottom and finally click on OK and reboot your.

  3. #3
    Join Date
    May 2009
    Posts
    42

    Delete a computer from a domain

    I also want to remove a computer from a domain but i need to implement this in Visual Basic code, i have heard from my friends that it's possible but don't know what will be the code for it. Can anyone provide me the code for the same. Thanks in advance.

  4. #4
    Join Date
    Nov 2005
    Posts
    403

    Delete a computer from a domain

    I try to use the following code to search and delete computer account from non-domain workstation and it worked for me, hope it works for you too.

    Code:
    Const ADS_SCOPESUBTREE = 2
    Const ADS_SECURE_AUTHENTICATION = 1
     
    Set objConnection = CreateObject("ADODB.Connection")
    Set objCommand =   CreateObject("ADODB.Command")
    objConnection.Provider = "ADsDSOObject"
    objConnection.Properties("User_ID") = "test\admin"
    objConnection.Properties("Password") = "home"
    objConnection.Properties("Encrypt_Password") = True
    objConnection.Properties("ADSI Flag") = 1
     
    strComputer = "test"
    strDomain = "srv.test.com"
     
    objConnection.Open "Active Directory Provider"
    Set objCommand.ActiveConnection = objConnection
     
    objCommand.Properties("Page Size") = 100
    objCommand.Properties("Cache_Results") = False
    objCommand.Properties("Search_scope") = ADS_SCOPESUBTREE
     
    objCommand.CommandText = _
        "SELECT ADsPath FROM 'LDAP://" & strDomain & "' WHERE objectCategory='computer' " & _
            "AND Name='" & strComputer & "'"
    Set objRecordSet = objCommand.Execute
     
    objRecordSet.MoveFirst
     
    strADsPath = ""
    While Not objRecordSet.EOF
        strADsPath = objRecordSet.Fields("ADsPath").Value
        objRecordSet.MoveNext
    Wend
    If strADsPath = "" Then
          MsgBox "Computer not yet found."
    Else
          MsgBox "Computer path: " & strADsPath
          Set objNS = GetObject("LDAP:")
          Set objComputer =  objNS.OpenDSObject(strADsPath, "test\admin", "home",ADS_SECURE_AUTHENTICATION)
            objComputer.DeleteObject (0)
    End If

Similar Threads

  1. Access to a sub domain with a computer in another domain
    By scots_gal in forum Active Directory
    Replies: 1
    Last Post: 16-05-2011, 01:45 AM
  2. How to Delete Domain!
    By Luther in forum Technology & Internet
    Replies: 2
    Last Post: 07-11-2008, 06:34 PM
  3. Join computer to domain without domain admins right
    By ridergroov in forum Active Directory
    Replies: 2
    Last Post: 09-10-2008, 03:08 AM
  4. Replies: 1
    Last Post: 18-08-2008, 10:17 PM
  5. Unable to access domain shares from a non domain computer
    By Joe Thomas in forum Windows Server Help
    Replies: 7
    Last Post: 26-06-2006, 11:19 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,017,967.20440 seconds with 17 queries