Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Exchange
2000.active.directory
2000.admin
2000.announcements
2000.app.conversion
2000.applications
2000.clients
2000.clustering
2000.connectivity
2000.development
2000.documentation
2000.general
2000.information.store
2000.interop
2000.kms
2000.misc
2000.protocols
2000.realtime.collabo.
2000.setup
2000.transport
2000.win2000
admin
application.conversion
applications
clients
clustering
connectivity
design
development
misc
mobility
setup
tools
  
 
date: Sat, 17 Feb 2007 21:09:03 -0800,    group: microsoft.public.exchange.development        back       


ExpandDL - "Try again later" error even after successful ResolveNa   
First, I love all the new web services so thanks a lot for those.

My problem is in getting the ExpandDL to work.  I got a vague error message 
when running even a simple example (like from the documentation).  Here is 
the error message I receive:
Active Directory operation did not succeed. Try again later.

Just to make sure I was connecting properly and such, I tried doing a 
ResolveNames on the alias first.  Then, I set the Mailbox on the ExpandDL 
request to the one I got returned from the ResolveNames with the very same 
ExchangeServiceBinding instance, and I still got the exact same error.

Is this a known issue, or is there something obvious I could be doing wrong?

That's my main question, and I'm not asking for someone to go through this, 
but if anyone is interested here's the C#:

            ExchangeServiceBinding esb = new ExchangeServiceBinding();
            esb.Url = "[edited out]";
            esb.Timeout = 300000000;
            esb.Credentials = new NetworkCredential([edited out]);

            ResolveNamesType rnt = new ResolveNamesType();
            rnt.ReturnFullContactData = true;
            rnt.UnresolvedEntry = [edited out];

            ResolveNamesResponseType rnrmt = esb.ResolveNames(rnt);

            Console.WriteLine(rnrmt.ToString());
            ResponseMessageType[] types = rnrmt.ResponseMessages.Items;
            if (types == null)
            {
                Console.WriteLine("Error! null returned");
            }
            else if (types.Length < 1)
            {
                Console.WriteLine("0 results returned");
            }
            else
            {
                ResponseMessageType type = types[0];
                if (types.Length > 1)
                {
                    Console.WriteLine("More than 1 (" + types.Length + ") 
record returned, taking first");
                }
                Console.WriteLine("Success! " + type.ToString());
                ResolveNamesResponseMessageType type2 = type as 
ResolveNamesResponseMessageType;

                if (type2.ResolutionSet.Resolution.Length < 1)
                {
                    Console.WriteLine("No resolved names");
                }
                else
                {
                    ContactItemType contact = 
type2.ResolutionSet.Resolution[0].Contact;
                    if(type2.ResolutionSet.Resolution.Length > 1)
                        Console.WriteLine("More than 1 (" + 
type2.ResolutionSet.Resolution.Length + ") resolved name returned");
                    Console.WriteLine("Display Name: " + contact.DisplayName);
                    if(contact.EmailAddresses.Length < 1)
                        Console.WriteLine("No email addresses listed");
                    else
                        Console.WriteLine("Email Addresses:");
                    for(int i = 0; i < contact.EmailAddresses.Length; i++)
                        
Console.WriteLine(contact.EmailAddresses[i].Key.ToString() + ": " + 
contact.EmailAddresses[i].Value.ToString());

                    Console.WriteLine("\r\n\r\nLooking into each address for 
expandedDL:");
                    for (int i = 0; i < contact.EmailAddresses.Length; i++)
                    {
                        LookupEmail(esb, 
type2.ResolutionSet.Resolution[0].Mailbox);
                    }
                }
            }


[separate function:]


        private static void LookupEmail(ExchangeServiceBinding esb, 
EmailAddressType eat)
        {
            Console.WriteLine("Looking up " + eat.ToString());
            ExpandDLType expandDl = new ExpandDLType();
            expandDl.Mailbox = eat;
            //expandDl.Mailbox.EmailAddress = email;

            // Expand the dl
            ExpandDLResponseType expandDlResponse = esb.ExpandDL(expandDl);

            // Check the result
            if (expandDlResponse.ResponseMessages.Items.Length > 0 &&
                expandDlResponse.ResponseMessages.Items[0].ResponseClass == 
ResponseClassType.Success)
            {
                ExpandDLResponseMessageType dlResponse = 
expandDlResponse.ResponseMessages.Items[0] as ExpandDLResponseMessageType;

                // Get the dl expansion list
                ArrayOfDLExpansionType expansionList = dlResponse.DLExpansion;

                // Display the dl members
                foreach (EmailAddressType address in expansionList.Mailbox)
                {
                    Console.WriteLine("Email Address: {0}", 
address.EmailAddress);
                }
            }
            else if (expandDlResponse.ResponseMessages.Items.Length > 0)
            {
                Console.WriteLine("Error: " + 
expandDlResponse.ResponseMessages.Items[0].MessageText);
            }
            else
                Console.WriteLine("No results returned");
        }
date: Sat, 17 Feb 2007 21:09:03 -0800   author:   jedimonkeys

RE: ExpandDL - "Try again later" error even after successful ResolveNa   
I couldn't figure this out, so I learned about this LDAP/DirectoryEntry 
ActiveDirectory stuff and it appears to be working great and fast.  I have a 
feeling the "web service" route is more current and will likely be around 
longer, so if anyone knows the answer to my previous problem please feel free 
to reply and I'd appreciate it.

I initially was trying this because there's limited MAPI support in C# and 
iterating through the whole address book would have taken days.  In case 
anyone else has this problem, I personally found the ActiveDirectory 
documentation difficult to navigate so here's a quick example ([] = edited 
out):

            DirectoryEntry de = new 
DirectoryEntry("LDAP://a.b.com/OU=Distribution Lists,DC=a,DC=b,DC=com", 
@"[domain\username]", "[password]");
            DirectorySearcher ds = new DirectorySearcher();
            ds.SearchRoot = de;

            ds.Filter = "(SAMAccountName=[DL alias (e.g. the DL c@b.com 
would be just c)])";
            ds.SearchScope = SearchScope.Subtree;

//this next part could use more robustness in case there's multiple results, 
errors, etc.
            SearchResult results = ds.FindOne();
            if (results.Properties["member"] != null)
            {
                foreach (string s in results.Properties["member"])
                    Console.WriteLine("Member: " + s);
            }

The connection string is the hardest to figure out.  And the "LDAP" has to 
be upper case or else.  Here it is again:
"LDAP://a.b.com/OU=Distribution Lists,DC=a,DC=b,DC=com"
--a.b.com should be self-explanatory
--Distribution Lists: this might not be the same for you, that's just what 
the DL list was called in the tree I was using.  You can open the connection 
without this part of the connection string (e.g. 
"LDAP://a.b.com/DC=a,DC=b,DC=com") and do the same sort of search with the 
search string "(OU=*)", the results of property "ou" instead of "member" will 
give you all the "organizational units" to look through to find the DL one
--If you have a different subdomain structure, just keep adding or removing 
"DC=X," until you spell it all out (e.g. "DC=a,DC=b,DC=c,DC=com" for 
a.b.c.com)
--When you get these results back you will see they are in this same crazy 
format, like "CN=[Name],OU=[something like "Accounts"],DC=a,DC=b,DC=com".  If 
you need the alias, you can make a new DirectoryEntry with this string and 
get the "mail" property for the email address.  Also if someone is on a DL 
which is on a DL and you're searching the top one, you will need to recurse 
through; instead of just checking for the email of each result check if you 
need to expand it to a DL (property OU="Distribution Lists" or the equivalent 
in your tree) and then reconnect there and search for subDLs.
--also if you want the groups a specific user is in, make one of the search 
strings for that user (try search filter "(SAMAccountName=[alias])"), then 
look up the all the groups they're in using the "memberof" property.

Hopefully this helps someone else having the same problem, but if not oh 
well. :)

This isn't formal or ideal or anything, so there's probably much better ways 
to do all this (and this ActiveDirectory stuff appears to often have many 
ways to query the same thing).


"jedimonkeys" wrote:

> First, I love all the new web services so thanks a lot for those.
> 
> My problem is in getting the ExpandDL to work.  I got a vague error message 
> when running even a simple example (like from the documentation).  Here is 
> the error message I receive:
> Active Directory operation did not succeed. Try again later.
> 
> Just to make sure I was connecting properly and such, I tried doing a 
> ResolveNames on the alias first.  Then, I set the Mailbox on the ExpandDL 
> request to the one I got returned from the ResolveNames with the very same 
> ExchangeServiceBinding instance, and I still got the exact same error.
> 
> Is this a known issue, or is there something obvious I could be doing wrong?
> 
> That's my main question, and I'm not asking for someone to go through this, 
> but if anyone is interested here's the C#:
> 
>             ExchangeServiceBinding esb = new ExchangeServiceBinding();
>             esb.Url = "[edited out]";
>             esb.Timeout = 300000000;
>             esb.Credentials = new NetworkCredential([edited out]);
> 
>             ResolveNamesType rnt = new ResolveNamesType();
>             rnt.ReturnFullContactData = true;
>             rnt.UnresolvedEntry = [edited out];
> 
>             ResolveNamesResponseType rnrmt = esb.ResolveNames(rnt);
> 
>             Console.WriteLine(rnrmt.ToString());
>             ResponseMessageType[] types = rnrmt.ResponseMessages.Items;
>             if (types == null)
>             {
>                 Console.WriteLine("Error! null returned");
>             }
>             else if (types.Length < 1)
>             {
>                 Console.WriteLine("0 results returned");
>             }
>             else
>             {
>                 ResponseMessageType type = types[0];
>                 if (types.Length > 1)
>                 {
>                     Console.WriteLine("More than 1 (" + types.Length + ") 
> record returned, taking first");
>                 }
>                 Console.WriteLine("Success! " + type.ToString());
>                 ResolveNamesResponseMessageType type2 = type as 
> ResolveNamesResponseMessageType;
> 
>                 if (type2.ResolutionSet.Resolution.Length < 1)
>                 {
>                     Console.WriteLine("No resolved names");
>                 }
>                 else
>                 {
>                     ContactItemType contact = 
> type2.ResolutionSet.Resolution[0].Contact;
>                     if(type2.ResolutionSet.Resolution.Length > 1)
>                         Console.WriteLine("More than 1 (" + 
> type2.ResolutionSet.Resolution.Length + ") resolved name returned");
>                     Console.WriteLine("Display Name: " + contact.DisplayName);
>                     if(contact.EmailAddresses.Length < 1)
>                         Console.WriteLine("No email addresses listed");
>                     else
>                         Console.WriteLine("Email Addresses:");
>                     for(int i = 0; i < contact.EmailAddresses.Length; i++)
>                         
> Console.WriteLine(contact.EmailAddresses[i].Key.ToString() + ": " + 
> contact.EmailAddresses[i].Value.ToString());
> 
>                     Console.WriteLine("\r\n\r\nLooking into each address for 
> expandedDL:");
>                     for (int i = 0; i < contact.EmailAddresses.Length; i++)
>                     {
>                         LookupEmail(esb, 
> type2.ResolutionSet.Resolution[0].Mailbox);
>                     }
>                 }
>             }
> 
> 
> [separate function:]
> 
> 
>         private static void LookupEmail(ExchangeServiceBinding esb, 
> EmailAddressType eat)
>         {
>             Console.WriteLine("Looking up " + eat.ToString());
>             ExpandDLType expandDl = new ExpandDLType();
>             expandDl.Mailbox = eat;
>             //expandDl.Mailbox.EmailAddress = email;
> 
>             // Expand the dl
>             ExpandDLResponseType expandDlResponse = esb.ExpandDL(expandDl);
> 
>             // Check the result
>             if (expandDlResponse.ResponseMessages.Items.Length > 0 &&
>                 expandDlResponse.ResponseMessages.Items[0].ResponseClass == 
> ResponseClassType.Success)
>             {
>                 ExpandDLResponseMessageType dlResponse = 
> expandDlResponse.ResponseMessages.Items[0] as ExpandDLResponseMessageType;
> 
>                 // Get the dl expansion list
>                 ArrayOfDLExpansionType expansionList = dlResponse.DLExpansion;
> 
>                 // Display the dl members
>                 foreach (EmailAddressType address in expansionList.Mailbox)
>                 {
>                     Console.WriteLine("Email Address: {0}", 
> address.EmailAddress);
>                 }
>             }
>             else if (expandDlResponse.ResponseMessages.Items.Length > 0)
>             {
>                 Console.WriteLine("Error: " + 
> expandDlResponse.ResponseMessages.Items[0].MessageText);
>             }
>             else
>                 Console.WriteLine("No results returned");
>         }
date: Sun, 18 Feb 2007 11:49:02 -0800   author:   jedimonkeys

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us