Exchange EWS: How to get all appointments in a room - resources

I am trying to get all Appointments of a Room in Exchange via Exchange EWS.
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.UseDefaultCredentials = true;
service.AutodiscoverUrl("hans.muster#domain.com", RedirectionUrlValidationCallback);
// Return all the room lists in the organization.
EmailAddressCollection roomLists = service.GetRoomLists();
System.Collections.ObjectModel.Collection<EmailAddress> rooms = service.GetRooms("ZimmerZuerich#domain.com");
EmailAddress roomAdress = rooms[31];
FolderId folderid = new FolderId(WellKnownFolderName.Calendar, new Mailbox(roomAdress.Address));
FindItemsResults<Appointment> aps = service.FindAppointments(folderid, new CalendarView(DateTime.Now, DateTime.Now.AddHours(24)));
If I run this code I get an error message stating:
{"The specified folder could not be found in the store."}.
And indeed if I show me a collection of all folders for such a room mailbox, there are no folders inside it.
What am I doing wrong? All examples in the internet work with WellKnownFolderName.Calendar.

That error generally indicates your credentials are okay to connect to Exchange but you don't have rights to the calendar you're trying to access so you either need to grant access to the Mailbox using Add-MailboxPermission or Grant Access to the Calendar Folder using Add-MailboxFolderPermissions
Cheers
Glen

Related

IBM Domino 10 - Java XPage create session or compare credentials of another user

I'm writing Java code in an XPage Rest Service basing on https://setza-projects.atlassian.net/wiki/spaces/RSD/pages/44007659/IBM+Domino which is an REST service written in Java used to handle Resource Reservations database. However the way it currently works, it creates the reservations for the current session user only:
private JsonObject createIntanceAppointment(ResourceDefinition rd, Database reDatabase, Date dtStart, Date dtEnd, String subject) throws NotesException {
Session session = reDatabase.getParent();
Name nnOrganizier = session.createName(session.getEffectiveUserName());
Name nnREsource = session.createName(rd.getFullName());
DateTime dt_startDateUTC = session.createDateTime(dtStart);
DateTime dt_endDateUTC = session.createDateTime(dtEnd);
Document doc = reDatabase.createDocument();
doc.replaceItemValue("form", "Reservation");
doc.replaceItemValue("Purpose", subject);
doc.replaceItemValue("ReservedFor", nnOrganizier.getCanonical());
doc.replaceItemValue("ResourceName", nnREsource.getAbbreviated());
doc.replaceItemValue("ResNameFormat", nnREsource.getAbbreviated());
I'm doing a very similar integration with Domino, although I'd prefer to have the reservations created for individual users (they provide their username & password on the room-booking application on a touch screen).
I could just authenticate as the user in my REST client, but if I understand the installation requirements for that RoomZ api correctly, the 'api managing user' needs to be exclusively signed to the database, so I would need to do that for every user in Domino that could make reservations.
I tried using NotesFactory.createSession("", "user", "password"); but that doesn't work, it gives Cannot create a session from an agent error
If I cannot create another session, is there any way I could verify that the username and password passed to the API in the payload is correct (to verify if the user can login)? Then I could just set the organizer/reserved for to this user.
Also, is there any way to make these reservation also appear in the organizer's Notes calendar? Currently they are succesfully created in the Reservations database and all, but the organizer is unaware of them despite he's assigned to the reservation.
You do not need to create a session for every user. The important thing is the nnOrganizer = session.createName(" ") which should contain the user. Probably you'll also need to set additional fields like chair or from for the reservation.
If you want to have some entries in the organizers calendar, send them a proper invitation or create a calendar entry in their mailfile.

How to send email notification to subscribers when adding file programmatically to document and media folder in liferay

I have more than one user having admin roles who are subscribed to a common folder which store some sort of images and documents. When one user add some images in the folder a notification email is sent to the subscribed user who has the view permission.
My Problem starts from here when I upload the images through the portal, email notification is sent successfully. But when I try to save the image using the following code the email notification is not send.
**
_dlAppLocalService.addFileEntry(userId, companyGroup.getGroupId(), folder.getFolderId(), fileName,
ContentTypes.TEXT_CSV_UTF8, fileContent.getBytes(), serviceContext);
**
For further explanation :- This particular code is triggered inside the Schedular so I'm creating ServiceContext as follows:-
long companyId = _portal.getDefaultCompanyId();
Company company = _companyLocalService.getCompany(companyId);
Group companyGroup = _groupLocalService.getCompanyGroup(companyId);
User defaultUser = company.getDefaultUser();
long userId = defaultUser.getUserId();
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(companyId);
serviceContext.setUserId(userId);
and then passing service context inside the above method.
I found that request and themeDisplay are coming as null in com.liferay.portlet.documentlibrary.util.DLImpl.startWorkflowInstance(long, DLFileVersion, String, ServiceContext) which leads to blankEntryURL and com.liferay.portlet.documentlibrary.service.impl.DLAppHelperLocalServiceImpl.notifySubscribers(long, FileVersion, String, ServiceContext) method fails to execute.
Can anyone help?. How I can get the file entryURL without having objects of themeDisplay and request?
You can avoid blank entryURL adding the line below before the call to addFileEntry():
serviceContext.setAttribute("entryURL", "anyNotEmptyURL");
But it is not enough for the method notifySubscribers() to run to the end. You need to add another line of code:
serviceContext.setCommand(Constants.ADD);
Unless a proper command value, the notification will be aborted.

How to programmatically create a bookmark for another connections user?

We want to create bookmarks programmatically and this works fine if the email parameter matches the account of the currently authenticated user.
The question is, how can we create a bookmark for another user ?
Below is the pseudo we use from the SBT.
String apiPath = "/dogear/api/app";
Response<String> postResponse = restClient.doPost(apiPath).parameter("email","another users email").body(body, "application/atom+xml").asString();
The log files are not very helpful, in the client we get an ERROR 400 Bad Request

EnsureUser not returning valid User

I am trying to get a user back in SharePoint Client OM using EnsureUser. My code is:
ClientContext clientContext = new ClientContext(siteUrl);
User spUser = clientContext.Web.EnsureUser(user);
Where siteUrl and user are both strings set as appropriate.
The result is spUser is the shell of a User object but all its properties (for example Email, Title, etc.) are not initialized. In VS they are showing {"The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested."}
What would be causing this? I thought EnsureUser would create the user if it is not already there. I know in Server OM sometimes you need to use "AllowUnsafeUpdates", is there something like that for Client OM?
It is almost a year late, but just in case someone else is searching for the same answer.
After getting a reference to the user object you need to do the following before accessing the properties of the user.
clientContext.Load(spUser);
clientContext.ExecuteQuery();
or if you want to get the email and title only to reduce the pay load.
clientContext.Load(spUser, u => u.Email, u => u.Title);
clientContext.ExecuteQuery();
Basically, it establishs a request to the SharePoint Web and ask for the properties of the spUser. The request will be send when ExecuteQuery() is called.

Retrieve GMail data through DotNetOpenId

I'm Trying to login with dotNetOpenId to GMail accounts. It works but I'm not able to retrieve any claims. I know I could retrieve email addresses or user names as well, but no claims are being returned only the ClaimedIdentifier is available. Anyone know how to retrieve this data from Gmail accounts? If you could please provide me an example of ClaimsRequest configuration I would be grateful.
Thanks
// Either you're creating this already or you can get to it in
// the LoggingIn event of the control you're using.
IAuthenticationRequest request;
// Add the AX request that says Email address is required.
var fetch = new FetchRequest();
fetch.Attributes.Add(
new AttributeRequest(WellKnownAttributes.Contact.Email, true));
request.AddExtension(fetch);
Google then authenticates the user and returns the email address, which you can get with:
var fetch = openid.Response.GetExtension<FetchResponse>();
if (fetch != null)
{
IList<string> emailAddresses = fetch.GetAttribute(
WellKnownAttributes.Contact.Email).Values;
string email = emailAddresses.Count > 0 ? emailAddresses[0] : null;
}
You can see my blog post on the subject for a bit more information. The important thing to note here is that Google will only tell you the user's email address if you mark it as required (as I have done in the above snippet). But this also means that if the user does not want to share his email address, he cannot log in at all. Sorry, that's the way Google set it up. Other Providers that people use have different behaviors, unfortunately.

Resources