c# - Get Direct Reports from Logged in user from Exchange -
i need direct reports logged in user (mvc 4) don't need names of direct reports need email addresses including proxy addresses. reason need search through exchange. have never attempted search exchange in past , find out there tells me how step 8 finish line says nothing how go step 1 8.
i can current users user name
user.identity.name.replace(@"yourdomain\", "")
and have found example far best example have found http://msdn.microsoft.com/en-us/library/office/ff184617(v=office.15).aspx
but example line
outlook.addressentry currentuser = application.session.currentuser.addressentry;
is not getting current user logged site.
i hope out there familiar , can me past point.
i reworked sample url following linqpad 4 query. i've found linqpad great way experiment because scripty, allowing quick experimentation, , can view data using dump()
extension method. purchasing intellisense support totally worthwhile.
also, noticed there lot of fine print like:
the logged-on user must online method return addressentries collection; otherwise, getdirectreports returns null reference. production code, must test user being offline using _namespace.exchangeconnectionmode property, or _account.exchangeconnectionmode property multiple exchange scenarios.
and
if current user has manager, getdirectreports() called return addressentries collection represents address entries direct reports of user’s manager. if manager has no direct reports, getdirectreports returns addressentries collection has count of zero.
so there lot of assumptions exchange configured direct report relationships, , current user online...which believe brings lync equation. linqpad query useful you. copy , paste text editor , name .linq file extension. you'll able open in linqpad 4. btw: you're question caught attention because there talk @ work of pulling direct reports active directory. wish more helpful...good luck.
<query kind="program"> <reference><programfilesx86>\microsoft visual studio 12.0\visual studio tools office\pia\office15\microsoft.office.interop.outlook.dll</reference> <reference><programfilesx86>\microsoft visual studio 12.0\visual studio tools office\pia\office15\microsoft.office.interop.outlookviewctl.dll</reference> <namespace>microsoft.office.interop.outlook</namespace> </query> void main() { getmanagerdirectreports(); } // define other methods , classes here private void getmanagerdirectreports() { var app = new microsoft.office.interop.outlook.application(); addressentry currentuser = app.session.currentuser.addressentry; if (currentuser.type == "ex") { exchangeuser manager = currentuser.getexchangeuser().getexchangeusermanager(); manager.dump(); if (manager != null) { addressentries addrentries = manager.getdirectreports(); if (addrentries != null) { foreach (addressentry addrentry in addrentries) { exchangeuser exchuser = addrentry.getexchangeuser(); stringbuilder sb = new stringbuilder(); sb.appendline("name: " + exchuser.name); sb.appendline("title: " + exchuser.jobtitle); sb.appendline("department: " + exchuser.department); sb.appendline("location: " + exchuser.officelocation); sb.dump(); } } } } }
Comments
Post a Comment