?
Solved

ADSI - Trusted Domains - Find user

Posted on 2006-11-21
3
Medium Priority
?
538 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many of us need to configure DHCP server(s) in their environment. We can do that simply via DHCP console on server or using MMC snap-in on each computer with Administrative Tools installed in a network. But what if we have to configure many DHCP ser…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

762 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