Tuesday, December 13, 2011

How to Remove Child Domain - Manually

Removing Orphaned Domains from Active Directory

1) Determine the domain controller that holds the Domain Naming Master Flexible Single Master Operations (FSMO) role. To identify the server holding this role:
        1.1) Start the Active Directory Domains and Trusts Microsoft Management Console (MMC) snap-in from the Administrative Tools menu.
        1.2) Right-click the root node in the left pane titled Active Directory Domains and Trusts, and then click Operations Master.
        1.3) The domain controller that currently holds this role is identified in the Current Operations Master frame.NOTE: If this changed recently, not all computer may have received this change yet due to replication.
        For more information about FSMO roles, click the following article number to view the article in the Microsoft Knowledge Base:
    2) Verify that all servers for the domain have been demoted.
    3) Click Start, point to Programs, point to Accessories, and then click Command Prompt.
         At the command prompt, type: ntdsutil.
         Type: metadata cleanup, and then press ENTER.
         Type: connections, and then press ENTER. This menu is used to connect to the specific server on which the changes will occur. If the currently logged-on user is not a member of the Enterprise Admins group, alternate credentials can be supplied by specifying the credentials to use before making the connection. To do so, type: set creds domainname username password , and then press ENTER. For a null password, type: null for the password parameter.
        Type: connect to server servername (where servername is the name of the domain controller holding the Domain Naming Master FSMO Role), and then press ENTER. You should receive confirmation that the connection is successfully established. If an error occurs, verify that the domain controller being used in the connection is available and that the credentials you supplied have administrative permissions on the server.
        Type: quit, and then press ENTER. The Metadata Cleanup menu is displayed.
        Type: select operation target, and then press ENTER.
        Type: list domains, and then press ENTER. A list of domains in the forest is displayed, each with an associated number.
        Type: select domain number, and then press ENTER, where number is the number associated with the domain to be removed.
        Type: quit, and then press ENTER. The Metadata Cleanup menu is displayed.
        Type: remove selected domain, and then press ENTER. You should receive confirmation that the removal was successful. If an error occurs, please refer to the Microsoft Knowledge Base for articles on specific error messages.
        Type: quit at each menu to quit the NTDSUTIL tool. You should receive confirmation that the connection disconnected successfully.
see ref

IF it gives the error: "DsRemoveDsDomainW error 0x2162(The requested domain could not be deleted because there exist domain controllers that still host this domain."

THEN do the following
1) open mmc
2) go to add / remove snap-in and select ADSI-Edit & click ok
3) Right Click on ADSI-Edit and select "Configuration" under select a well known Naming Context. Click ok to exit
4)Under CN=Sites delete the child domain controllers from the respective site(s)

This should clear up the above error.

run the above step again - it should be able to complete sucessfully. IF you get this error "DsRemoveDsDomainW error 0x2015(The directory service can perform the requested operation only on a leaf object"

Use the following steps to get rid of the error.

    1) Click Start, click Run, type ntdsutil, and then press ENTER.
    At the Ntdsutil command prompt, type partition management, and then press ENTER.
    2) Type connections, and then press ENTER.
    3) Type connect to server Domain_Controller_Name, and then press ENTER.
    After the following message appears,"Connected to Domain_Controller_Name using credentials of locally logged on user" type quit, and then press ENTER:
    4) At the domain management prompt, type list, and then press ENTER.
    Note the following entry:
    DC=DomainDnsZones,DC=Child_Domain, DC=extension
    For example, if the child domain is let.do.com, note the following entry:
    Type the following command, and then press ENTER.
    delete nc dc=domaindnszones,dc=Child_Domain,dc=extension
    Note In this command, Child_Domain represents the name of the child domain that you want to remove. For example, if the child domain is let.do.com, type the following command, and then press ENTER:
    delete nc DC=DomainDnsZones,DC=let,DC=do,DC=com
    Quit Ntdsutil.

see ref
Once this is removed, then you can again remove the child domain using ntdsutil from the top.

It worked for me!

How to remove default Trust relationship between parent and child domain

Hello Guys,

I encountered a error with the trust relationship between my parent domain and child domain. I couldn't reset the trust password nor delete the trust.

I found a solution to this problem. I hope this helps.

"1. Run ADSIEdit in the parent domain.

2. While connecting select default naming context

3. Go to the System container.

4. You should see a TrustedDomain object called CN=<ChildDomainName> -> Delete this object.

5. Go to the Users container.

6. You should see a User object called CN=<ChildDomainName$> Delete this object.

7. Force Replicate throughout the parent domain so all DC's in the parent recognize this change.

8. Perform the steps 1-7 in the child domain as well (TrustedDomain & User object will show CN=<ParentDomainName> & CN=<ParentDomainName$>)

9. Once replicated, reboot the PDC in both domains.

10. In the parent domain, open Active Directory Domains and Trusts, create a new trust with the child domain (create on both sides).

In addition, please check the following:

1.    Verify that DNS works find in both domains.

2.    On the PDC in the parent domain, type the command nltest /dsgetdc:ChildDomain /force
On the PDC in the child domain, type the command nltest /dsgetdc:ParentDomain /force
and check the result."


Please note that it best that you have a backup copy of your domain controller (PDC) for both child and parent domain before proceeding with above steps.

Monday, December 5, 2011

how to get users from a shared folder

Hi there,

this is a very useful command for get users from a shared folder.

#Get the ACL on the existing folder

$USERACL = get-acl "\\server\share\folder"

#Show the ACL

write-host "ACL entry is "

$USERACL | format-list
Copy the above into a notepad, modify the  "\\server\share\folder" to your location of the share and save as a *.ps1 file.

Open Powershell and browse to your *.ps1 location and run it. it should give you a list BUT make sure that YOU too have permission on the share.

Alternatively after modifying share location, you can paste the commands directly in powershell and get the same results.