|
| Active directory search |
 |
Thu, 10 Apr 2008 15:03:00 -070 |
Hi,
without specifying the complete DN of an object and using [ADSI]"LDAP://
"
provider can i serach an object? assuming my AD has many OU and users are
|
| Post Reply
|
| Re: Active directory search |
 |
Thu, 10 Apr 2008 18:19:25 -040 |
not in v1 without modifying the type extensions.
This will do what your wanting
function Get-MyADUser($user="*"){
$filter = "(&(objectcategory=user)(sAMAccountName=$user)"
$ds = new-object
system.directoryservices.directorysearcher([adsi]"",$filter)
$ds.pagesize = 1000
$ds.findall() | %{$_.GetDirectoryEntry()}
}
"Swamy Channaveera" <SwamyChannaveera@discussions.microsoft.com>
wrote in
message news:D3315E43-B209-4895-9422-E4381049492D@microsoft.com...
> Hi,
>
> without specifying the complete DN of an object and using
[ADSI]"LDAP:// "
> provider can i serach an object? assuming my AD has many OU and users are
> spread across many OU?
|
| Post Reply
|
| Re: Active directory search |
 |
Thu, 10 Apr 2008 18:22:01 -040 |
Karl... just remember that findall() doesnt return DirectoryEntry and it
acts different. To get a DirectoryEntry you need to call the
GetDirectoryEntry() method on the returned object.
p.s. dont use objectclass ;)
"Karl Mitschke" <kmitschke@somestate.gov> wrote in message
news:7063857f344588ca693ce0bc2465@msnews.microsoft.com...
> Hello Swamy,
>
>> Hi,
>>
>> without specifying the complete DN of an object and using
>> [ADSI]"LDAP:// "
>> provider can i serach an object? assuming my AD has many OU and users
>> are
>> spread across many OU?
>
> $username = "swamy"
> $searcher = new-object
DirectoryServices.DirectorySearcher([ADSI]"")
> $searcher.filter = "(&(objectClass=user)(sAMAccountName=
$UserName))"
> $searcher.findall()
>
>
|
| Post Reply
|
| Re: Active directory search |
 |
Thu, 10 Apr 2008 22:12:58 +000 |
Hello Swamy,
> Hi,
>
> without specifying the complete DN of an object and using
> [ADSI]"LDAP:// "
> provider can i serach an object? assuming my AD has many OU and users
> are
> spread across many OU?
$username = "swamy"
$searcher = new-object
DirectoryServices.DirectorySearcher([ADSI]"")
$searcher.filter = "(&(objectClass=user)(sAMAccountName=
$UserName))"
$searcher.findall()
|
| Post Reply
|
| Re: Active directory search |
 |
Fri, 11 Apr 2008 00:03:00 -070 |
You are right There is no findall() and getdirectoryentry() method may be
with V2 it is available.
"Brandon Shell [MVP]" wrote:
> not in v1 without modifying the type extensions.
>
> This will do what your wanting
>
> function Get-MyADUser($user="*"){
> $filter =
"(&(objectcategory=user)(sAMAccountName=$user)"
> $ds = new-object
> system.directoryservices.directorysearcher([adsi]"",$filter)
> $ds.pagesize = 1000
> $ds.findall() | %{$_.GetDirectoryEntry()}
> }
>
> "Swamy Channaveera"
<SwamyChannaveera@discussions.microsoft.com> wrote in
> message news:D3315E43-B209-4895-9422-E4381049492D@microsoft.com...
> > Hi,
> >
> > without specifying the complete DN of an object and using
[ADSI]"LDAP:// "
> > provider can i serach an object? assuming my AD has many OU and users
are
> > spread across many OU?
|
| Post Reply
|
|
|
|
|
|
|
|
|
|