4

I'm trying to find some ActiveSync attributes from Exchange. I found a good article that shows a PowerShell cmdlet for finding this information. But I'm trying to find where this information is actually stored. I looked at my user objects in ADSI edit to see if any of the properties would be these values, but this does not seem to be the case. How do I find this information with C#?

Anthony Mastrean
  • 21,850
  • 21
  • 110
  • 188
Kyle
  • 17,317
  • 32
  • 140
  • 246
  • You could use the powershell & the cmdlet from C#, in process. Something similar to what can be found here: http://stackoverflow.com/questions/7560728/hosted-powershell-cannot-see-cmdlets-in-the-same-assembly – Simon Mourier Nov 15 '11 at 09:32
  • yes - that is possible... see my answer below. – Yahia Nov 16 '11 at 05:55

2 Answers2

0

Get-CASMailbox will give you basic information such as HasActiveSyncDevicePartnerShip. These properties are stored in active directory, you can view them with adsiedit right under the person account.

If you want more properties like DeviceFriendlyName, LastSuccessSync, DeviceImei, they have to be retrieved from the mailbox itself using the PS Cmdlet Get-MobileDeviceStatistics.

There are several methods to use PS CmdLets inside C# code, for exchange you will probably want to use PS Remoting : https://stackoverflow.com/a/9627716/1984242

miljbee
  • 300
  • 3
  • 8
0

To get ActiveSync attributes for a specific ActiveDirectory Object (i.e. user) you can use CASMailbox class.

It has a constructor taking an ADObject and then gives you several properties like HasActiveSyncDevicePartnership - you can even change these (provided you have needed permissions that is).

EDIT - as per comments:

The CASMailbox class has all you ask.
For example ActiveSyncMailboxPolicy which is an ADObjectId which in turn can be queried for several properties...
Another example ActiveSyncAllowedDeviceIDs which is a MultiValuedProperty which you can query for DeviceIDs etc.

This way of accessing the properties might not be nice but it certainly gives you all information... if you want some rather nice source code (which in this case works with PS) see http://www.java2s.com/Open-Source/CSharp/Web/dotpanel/dotPanel/Providers/HostedSolution/Exchange2007.cs.htm

Yahia
  • 69,653
  • 9
  • 115
  • 144
  • While this class does give me the 'HasActiveSyncDevicePartnership' property, it does not look to expose any of the actual ActiveSync attributes such as DeviceType, DeviceID, etc. – Kyle Nov 16 '11 at 17:46