Solved

ADSI - Trusted Domains - Find user

Posted on 2006-11-21
3
510 Views
Last Modified: 2008-01-09
Hi i need to find user in AD (email, full name )  and as input is domaintname\username

there are 4 domains trees which are trusted.
oldCompany1, oldcompany2, newADDirectory1, newADDirectory2

and i'd like to know how i can find the  user, in any domain without need to  explicitly specify the LDAP connection string for each domain,  
There have to be same list of all trusted trees.


0
Comment
Question by:winzig
3 Comments
 
LVL 14

Expert Comment

by:inbarasan
ID: 17986820
The simple thing you can do is Click on Start--> Search-->Choose "For People"

In that you choose Active directory and give search. It will find.
0
 
LVL 10

Author Comment

by:winzig
ID: 17988952
But i need perform this operation from script.
I mentioned ADSI because i suppose that  people  in this group are more familiar with this interface, but final code will be written in .NET.

0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 17989424
Greetings, winzig.

This is possible with a bit of fairly simple scripting too.  Something like this:

    Dim varArgument, arrParameters, adoCon, strConnection, adoRS
    varArgument = WScript.Arguments(0)
    If varArgument <> "" Then
        arrParameters = Split(varArgument, "\")
        Set adoCon = CreateObject("ADODB.Connection")
        With adoCon
            .Provider = "ADsDSOObject"
            .Open "Active Directory Provider"
        End With
        strConnection = "SELECT mail, displayName  FROM 'LDAP://" & arrParameters(0) & "' WHERE objectClass='user' AND objectCategory='Person' AND samAccountName ='" & arrParameters(1) & "'"
        Set adoRS = adoCon.Execute(strConnection)
        If Not adoRS.EOF Then
            Wscript.Echo varArgument & " is " & adoRS.Fields("displayName") & vbCrLf & "Email address is " & adoRS.Fields("mail")
        Else
            Wscript.Echo varArgument & " was not found in AD."
        End If
    End If
    Set adoRS = Nothing
    Set adoCon = Nothing

Usage would be

    scriptname.vbs domain\username

Cheers!
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This may not be a text book method to resolve VSS backup issues but it seemed to have worked on few of the Windows 2003 servers we had issues while performing a Volume Shadow Copy backup. If you have issues while performing a shadow copy backup usin…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now