How to find Exchange Domain Servers element in LDAP / ADSI

How to find Exchange Domain Servers element in LDAP / ADSI

Post by Chris Rowe » Fri, 21 Jun 2002 06:09:04



I have some code (below) to enumerate the Exchange servers in an Exchange
2000 environment that assumes that the "\users\Exchange Domain Servers" key
will always exist under the CN=Users container.  If this element is renamed,
I am not sure how to find the list of Exchange servers through LDAP / ADSI.
What is the correct mechanism for doing this?

Thanks,

Chris

 if (SUCCEEDED(hr = ADsOpenObject(
      L"LDAP://rootDSE",
      NULL,
      NULL,
      ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
      IID_IADs,
      (void**)&pObject)))
 {
  if (SUCCEEDED(hr = pObject->Get(L"defaultNamingContext",&var)))
  {
   // Build path to the Computers container within the domain container
   wcscpy(szPath, L"LDAP://CN=Exchange Domain Servers, CN=Users,");
   wcscat(szPath, var.bstrVal);

   if (SUCCEEDED(hr = ADsGetObject(szPath, IID_IADs, (void**)&pADs)))

 
 
 

How to find Exchange Domain Servers element in LDAP / ADSI

Post by Michael Welte » Fri, 21 Jun 2002 14:09:18


Chris, do a search for them...

Filter = "(objectCategory=msExchExchangeServer)"
SearchRoot = "/CN=Microsoft Exchange,CN=Services," +
configurationNamingContext

If you only want the names use search against a GC w/ the GC:// provider.
Get the configurationNamingContext from the rootDSE

BTW: the "Exchange Domain Servers" group will ALWAYS be in the users
OU...Exchange 2000 won't work otherwise, at least SP2.  There is a KB
article about it somewhere.  You still wouldn't want to use this method
though.  The group is populated w/ AD computer objects which can have old
systems in there.


Quote:> I have some code (below) to enumerate the Exchange servers in an Exchange
> 2000 environment that assumes that the "\users\Exchange Domain Servers"
key
> will always exist under the CN=Users container.  If this element is
renamed,
> I am not sure how to find the list of Exchange servers through LDAP /
ADSI.
> What is the correct mechanism for doing this?

> Thanks,

> Chris

>  if (SUCCEEDED(hr = ADsOpenObject(
>       L"LDAP://rootDSE",
>       NULL,
>       NULL,
>       ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
>       IID_IADs,
>       (void**)&pObject)))
>  {
>   if (SUCCEEDED(hr = pObject->Get(L"defaultNamingContext",&var)))
>   {
>    // Build path to the Computers container within the domain container
>    wcscpy(szPath, L"LDAP://CN=Exchange Domain Servers, CN=Users,");
>    wcscat(szPath, var.bstrVal);

>    if (SUCCEEDED(hr = ADsGetObject(szPath, IID_IADs, (void**)&pADs)))


 
 
 

How to find Exchange Domain Servers element in LDAP / ADSI

Post by Michael Welte » Fri, 21 Jun 2002 14:09:57


Chris,

Do a search under the


Quote:> I have some code (below) to enumerate the Exchange servers in an Exchange
> 2000 environment that assumes that the "\users\Exchange Domain Servers"
key
> will always exist under the CN=Users container.  If this element is
renamed,
> I am not sure how to find the list of Exchange servers through LDAP /
ADSI.
> What is the correct mechanism for doing this?

> Thanks,

> Chris

>  if (SUCCEEDED(hr = ADsOpenObject(
>       L"LDAP://rootDSE",
>       NULL,
>       NULL,
>       ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
>       IID_IADs,
>       (void**)&pObject)))
>  {
>   if (SUCCEEDED(hr = pObject->Get(L"defaultNamingContext",&var)))
>   {
>    // Build path to the Computers container within the domain container
>    wcscpy(szPath, L"LDAP://CN=Exchange Domain Servers, CN=Users,");
>    wcscat(szPath, var.bstrVal);

>    if (SUCCEEDED(hr = ADsGetObject(szPath, IID_IADs, (void**)&pADs)))

 
 
 

How to find Exchange Domain Servers element in LDAP / ADSI

Post by Chris Rowe » Fri, 21 Jun 2002 22:47:44


Michael,

Thanks for the response.  In looking at my AD configuration with
LDAPBrowser, I don't see anything with objectCategory=msExchExchangeServer
or a CN=Microsoft Exchange.  Where are these in tree?

Thanks,

Chris


> Chris, do a search for them...

> Filter = "(objectCategory=msExchExchangeServer)"
> SearchRoot = "/CN=Microsoft Exchange,CN=Services," +
> configurationNamingContext

> If you only want the names use search against a GC w/ the GC:// provider.
> Get the configurationNamingContext from the rootDSE

> BTW: the "Exchange Domain Servers" group will ALWAYS be in the users
> OU...Exchange 2000 won't work otherwise, at least SP2.  There is a KB
> article about it somewhere.  You still wouldn't want to use this method
> though.  The group is populated w/ AD computer objects which can have old
> systems in there.



> > I have some code (below) to enumerate the Exchange servers in an
Exchange
> > 2000 environment that assumes that the "\users\Exchange Domain Servers"
> key
> > will always exist under the CN=Users container.  If this element is
> renamed,
> > I am not sure how to find the list of Exchange servers through LDAP /
> ADSI.
> > What is the correct mechanism for doing this?

> > Thanks,

> > Chris

> >  if (SUCCEEDED(hr = ADsOpenObject(
> >       L"LDAP://rootDSE",
> >       NULL,
> >       NULL,
> >       ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
> >       IID_IADs,
> >       (void**)&pObject)))
> >  {
> >   if (SUCCEEDED(hr = pObject->Get(L"defaultNamingContext",&var)))
> >   {
> >    // Build path to the Computers container within the domain container
> >    wcscpy(szPath, L"LDAP://CN=Exchange Domain Servers, CN=Users,");
> >    wcscat(szPath, var.bstrVal);

> >    if (SUCCEEDED(hr = ADsGetObject(szPath, IID_IADs, (void**)&pADs)))

 
 
 

How to find Exchange Domain Servers element in LDAP / ADSI

Post by Michael Welte » Sat, 22 Jun 2002 10:20:16


Chris,

Did you go under configurationNamingContext ?

You can get configurationNamingContext from rootDSE


> Michael,

> Thanks for the response.  In looking at my AD configuration with
> LDAPBrowser, I don't see anything with objectCategory=msExchExchangeServer
> or a CN=Microsoft Exchange.  Where are these in tree?

> Thanks,

> Chris



> > Chris, do a search for them...

> > Filter = "(objectCategory=msExchExchangeServer)"
> > SearchRoot = "/CN=Microsoft Exchange,CN=Services," +
> > configurationNamingContext

> > If you only want the names use search against a GC w/ the GC://
provider.
> > Get the configurationNamingContext from the rootDSE

> > BTW: the "Exchange Domain Servers" group will ALWAYS be in the users
> > OU...Exchange 2000 won't work otherwise, at least SP2.  There is a KB
> > article about it somewhere.  You still wouldn't want to use this method
> > though.  The group is populated w/ AD computer objects which can have
old
> > systems in there.



> > > I have some code (below) to enumerate the Exchange servers in an
> Exchange
> > > 2000 environment that assumes that the "\users\Exchange Domain
Servers"
> > key
> > > will always exist under the CN=Users container.  If this element is
> > renamed,
> > > I am not sure how to find the list of Exchange servers through LDAP /
> > ADSI.
> > > What is the correct mechanism for doing this?

> > > Thanks,

> > > Chris

> > >  if (SUCCEEDED(hr = ADsOpenObject(
> > >       L"LDAP://rootDSE",
> > >       NULL,
> > >       NULL,
> > >       ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
> > >       IID_IADs,
> > >       (void**)&pObject)))
> > >  {
> > >   if (SUCCEEDED(hr = pObject->Get(L"defaultNamingContext",&var)))
> > >   {
> > >    // Build path to the Computers container within the domain
container
> > >    wcscpy(szPath, L"LDAP://CN=Exchange Domain Servers, CN=Users,");
> > >    wcscat(szPath, var.bstrVal);

> > >    if (SUCCEEDED(hr = ADsGetObject(szPath, IID_IADs, (void**)&pADs)))

 
 
 

How to find Exchange Domain Servers element in LDAP / ADSI

Post by Chris Rowe » Sun, 23 Jun 2002 00:47:04


Thanks, I figured it out.

Once again, thanks for the help!

Chris


> Chris,

> Did you go under configurationNamingContext ?

> You can get configurationNamingContext from rootDSE



> > Michael,

> > Thanks for the response.  In looking at my AD configuration with
> > LDAPBrowser, I don't see anything with

objectCategory=msExchExchangeServer
> > or a CN=Microsoft Exchange.  Where are these in tree?

> > Thanks,

> > Chris



> > > Chris, do a search for them...

> > > Filter = "(objectCategory=msExchExchangeServer)"
> > > SearchRoot = "/CN=Microsoft Exchange,CN=Services," +
> > > configurationNamingContext

> > > If you only want the names use search against a GC w/ the GC://
> provider.
> > > Get the configurationNamingContext from the rootDSE

> > > BTW: the "Exchange Domain Servers" group will ALWAYS be in the users
> > > OU...Exchange 2000 won't work otherwise, at least SP2.  There is a KB
> > > article about it somewhere.  You still wouldn't want to use this
method
> > > though.  The group is populated w/ AD computer objects which can have
> old
> > > systems in there.



> > > > I have some code (below) to enumerate the Exchange servers in an
> > Exchange
> > > > 2000 environment that assumes that the "\users\Exchange Domain
> Servers"
> > > key
> > > > will always exist under the CN=Users container.  If this element is
> > > renamed,
> > > > I am not sure how to find the list of Exchange servers through LDAP
/
> > > ADSI.
> > > > What is the correct mechanism for doing this?

> > > > Thanks,

> > > > Chris

> > > >  if (SUCCEEDED(hr = ADsOpenObject(
> > > >       L"LDAP://rootDSE",
> > > >       NULL,
> > > >       NULL,
> > > >       ADS_SECURE_AUTHENTICATION, //Use Secure Authentication
> > > >       IID_IADs,
> > > >       (void**)&pObject)))
> > > >  {
> > > >   if (SUCCEEDED(hr = pObject->Get(L"defaultNamingContext",&var)))
> > > >   {
> > > >    // Build path to the Computers container within the domain
> container
> > > >    wcscpy(szPath, L"LDAP://CN=Exchange Domain Servers, CN=Users,");
> > > >    wcscat(szPath, var.bstrVal);

> > > >    if (SUCCEEDED(hr = ADsGetObject(szPath, IID_IADs,
(void**)&pADs)))

 
 
 

1. ADSI not finding LDAP

Hi,

When I run the following code

Set x = GetObject("ADs:")
For Each Provider In x
    Debug.Print Provider.Name
Next

I only get 1 result which is

IIS:

The NT4 server I'm connected to runs exchange 5.5 and IIS all with NTOptPack
and SP6.
Exchange is configured to use the LDAP protocol, and at the moment I'm not
requiring SSL.

Using VB, I'm trying to run:

ADsPath="LDAP://Exchgsrv/cn=Recipients,o=MyOrg,ou=MySite"
Set objcont = GetObject(ADsPath)

I get run time error -2147221020(800401e4)  - Automation Error, Invalid
Syntax.

The module has the OLE automation object, the ActiveDS IIS Namespace
Provider and the ActiveDS Type library.

Is there something missing? Maybe something not installed on the server?

Many thanks in advance,
Andy

2. HOW To Disable MAPI Clients(per user in domain ) from accesing to DataBase store

3. ADSI finding out default exchange server

4. Duplicated email massages ...

5. How to access LDAP server via ADSI?

6. Howto delete mail box messages without knowing users password?

7. ADSI/LDAP/Exchange Syntax

8. Searching all mailboxes for a specific word

9. LDAP/ADSI access to Exchange 5.5 public folder information

10. ADSI vs. LDAP for Exchange

11. ADSI/LDAP and Exchange...

12. Help: ADSI/LDAP to create Exchange Mailbox