“Syncing” outlook 2013 with Owncloud

Update: Although the below works, it’s not ideal.
I’ve recently discovered https://caldavsynchronizer.org/ which is an active project and works very well!



As some of you might know, i’m quite fond of my privacy. Together with the fact that i still run my own server at home, this resulted in me investing some time on OwnCloud. I use it to sync my contacts and some files that I use for work. It also makes my MP3’s accessable everywhere in the world. The android app is simple, but the thing i needed the most (backup of photo’s) is in there with a nice auto-upload over wifi option. I recently broke a Nexus 4 and was a bit bummed out because i couldn’t get my photo’s of it anymore.

Anyway, owncloud also has options to do calendar functionality. I used to sync my outlook calendar with google calendar via their Google Calendar Sync. The Calendar Sync is a bit buggy and one wonders why google doesn’t invest a bit more time into that. I decided that i wanted to sync my outlook calendar with OwnCloud so i could also access it from there.

Outlook 201x (in my case 2013) allows you to upload a ICS (iCalendar file) to a WebDav server. OwnCloud is a WebDav server and it would mean my ICS file is now backed up in owncloud. This is how i configured it:


You’ll now get this dialog:

Enter the URL of your owncloud WebDav link. This normally is https://servername/remote.php/webdav/

Go for advanced as well, and configure it like so:


After hitting OK, the first ICS file will be uploaded. That ICS file is just a file to OwnCloud. So those entries are not in your calendar yet. However, if you click on the file the OwnCloud web UI, you get this:


This is a *great* feature, as we know can create calendar entries from our ICS file.

It does a single web requirest to the owncloud server that imports the file, you can automate this with CURL:


curl --user username:password --data "progresskey=0&method=old&overwrite=1&calname=&path=%2F&file=FILENAME.ICS&id=4&calcolor="  https://servername/index.php/apps/calendar/ajax/import/import.php

I’m assuming the id=4 identifies the calendar you use. So you might need to change it. Important is also the filename.ICS
All that’s left is to crontab that and we’re done!

Add AD-Group to SP2010 via CSOM

Unfortunatly, projects aren’t always that fancy. In this case I’m still doing a bit of SP2010. Luckaly we do use CSOM to make it a bit interesting.
CSOM has a lot of functionality, and theoretically you can say “it does everything the old-fashioned SPSite model does”. However, it can be a struggle.

In this case, we needed to add a AD Group/User to sharepoint directly. Don’t ask, it’s a customer requirement. So, no SharePoint groups used.

In the end, this MSDN article was hugely useful.

Also note the usage of EnsureUsers which seems to work for groups as well!?

The permission parameter are the “Full Control” or “Read” permissions which are called “Permission Levels” in SharePoint itself. There’s a “level” below that called BasePermissions, for if you want to make it more complex for yourself :)

Here’s the bit of code that works for me:

        public static void AddSecurityGroup(string url, string loginName, string permission)
            using (ClientContext context = new ClientContext(url))
                context.Load(context.Web, w => w.RoleAssignments);
                context.Load(context.Web, w => w.HasUniqueRoleAssignments);
                if (!context.Web.HasUniqueRoleAssignments)
                    throw new ArgumentException("URL provided is not root for permissions. Did you break inheritence correctly? Because that's needed.");
                User u = context.Web.EnsureUser(loginName); //This also seems to work for groups.
                context.Load(u); // important as this actually loads the properties etc.
                RoleDefinition oRoleDefinition = context.Web.RoleDefinitions.GetByName(permission); 
                RoleDefinitionBindingCollection collRoleDefinitionBinding = new RoleDefinitionBindingCollection(context);
                RoleAssignment oRoleAssignment = context.Web.RoleAssignments.Add(u, collRoleDefinitionBinding);

Happy coding!