title: Getting a user's mailbox database in Exchange (2010) using C#
body: <p>I've been searching for a way to find out a user's mailbox database in Exchange and have not found anything other than powershell scripts.  I did find an autodiscover service that I thought would work but I'm not getting the response I thought I would.</p>
  
  <pre><code>        try
          {
              AutodiscoverService autodiscoverService = new AutodiscoverService("mynetwork.ext",ExchangeVersion.Exchange2010);
              autodiscoverService.Credentials = new NetworkCredential("Administrator@mynetwork.ext", "mypassword");
  
              // Get the user settings.
              // Submit a request and get the settings. The response contains only the
              // settings that are requested, if they exist. 
  
              GetUserSettingsResponse autoResponse = autodiscoverService.GetUserSettings(
                  "testuser@theusersdomain.com",
                  UserSettingName.UserDN,
                  UserSettingName.MailboxDN
                  );
  
          }
  </code></pre>
  
  <p>According to MS's documentation, "MailboxDN" is supposed to be the mailbox distinguished name.  <a href="http://msdn.microsoft.com/en-us/library/exchange/dd633650(v=exchg.80).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/exchange/dd633650(v=exchg.80).aspx</a>   - "MailboxDN  - The distinguished name of the mailbox database of the user's mailbox."</p>
  
  <p>However, what I get from the response is: "{[MailboxDN, /o=MyMail/ou=Exchange Administrative Group
  /(EYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=EXCHANGESERVER/cn=Microsoft Private MDB]}"</p>
  
  <p>The actual message database the user is in is "test1".</p>
  
  <p>Does anyone know how to retrieve this information?</p>
  
  <p>Thanks!</p>