Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8892195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:56:08+00:00 2026-06-14T22:56:08+00:00

I’m trying to learn some sys-admin type stuff on the side, and am very

  • 0

I’m trying to learn some sys-admin type stuff on the side, and am very new at this. My question seems simple, but I can’t seem to find a way to do this. Here’s the scenario:

  • I have setup 2 Windows Server 2012 machines under Hyper-V on my laptop
  • I setup new forests on both and promoted each one to a DC. Lets say one domain is called mydomain.com, and the other is called yourdomain.com. There is a 2 way trust between both domains, and I have validated that trust.
  • I have added some dummy users in mydomain.com and yourdomain.com, some with the same names and some with different ones

Now, what I want to do is to check which users in mydomain.com exist in yourdomain.com as well. For instance, I have a user called “fred.flintstone” in mydomain.com, and I want to check if he exists in yourdomain.com as well.

I am limited to using VBScript/Perl/Python/Batchfile and/or the DS tools (like dsquery,dsget etc), unfortunately powershell is out (for now)

Any pointers on how to script this would be welcome.

Thanks in advance

PS:
The goal of this exercise is eventually to check all the groups in mydomain.com, and check to see if those groups exist in yourdomain.com as well. If they exists, then move the users from mydomain.com into yourdomain.com in the corresponding groups, and if they don’t exist, then create the group in yourdomain.com and create the corresponding user.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:56:10+00:00Added an answer on June 14, 2026 at 10:56 pm

    I managed to write the VBScript which does what I wanted, so I will share it here. The script probably needs a very good cleanup, but for now it does the job so I’m hoping it can help other people too.

    ' Get OU
    
    strOU1 = "OU=here,DC=mydomain,DC=com"
    strOU2 = "OU=there,DC=yourdomain,DC=com"
    
    Dim samid
    Dim ldap_command
    
    ' Create connection to AD
    '
    Set objConnection = CreateObject("ADODB.Connection")
    objConnection.Open "Provider=ADsDSOObject;"
    
    ' Create command
    '
    Set objCommand1 = CreateObject("ADODB.Command")
    objCommand1.ActiveConnection = objConnection
    objCommand1.Properties("Page Size") = 1000
    
    ' Execute command to get all users in OU
    '
    objCommand1.CommandText = _
      "<LDAP://" & strOU1 & ">;" & _
      "(&(objectclass=user)(objectcategory=person));" & _
      "adspath,distinguishedname,sAMAccountName;subtree"
    
    Set objRecordSet = objCommand1.Execute
    
    ' Show info for each user in OU
    '
    Do Until objRecordSet.EOF
    
      ' Show required info for a user
      '  
       samid = objRecordSet.Fields("sAMAccountName").Value
       WScript.Echo "Processing " & objRecordSet.Fields("sAMAccountName").Value
       Set objCommand2 = CreateObject("ADODB.Command")
       ldap_command = _
       "<LDAP://" & strOU2 & ">;" & _
       "(&(objectclass=user)(objectcategory=person)" & _
       "(sAMAccountName=" & samid & "));" & _
       "adspath,distinguishedname,sAMAccountName;subtree"
    
       objCommand2.CommandText = ldap_command
    
       objCommand2.ActiveConnection = objConnection 
       objCommand2.Properties("Chase referrals") = &H40  
    
       Set objRecordSet2 = objCommand2.Execute
    
       If objRecordSet2.RecordCount = 0 Then
          Wscript.Echo "The sAMAccountName is not in use."
       Else
          Wscript.Echo "This ID is in use"
       End If
    
      ' Move to the next user
      '
       objRecordSet.MoveNext
    
    Loop
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.