1

Topic: iRedmail + Nextcloud + MySQL identity integration

I've got iRedMail 0.9.9 MySQL version running on FreeBSD. All is good. I also run Nextcloud for file sharing, calendar sharing, and its many features. By installing the  User SQL plugin on Nextcloud, I can link the identities I define in iRedMail and that are used in Nextcloud. If a user exists in my iRedMail setup, they will automatically get access to all the features of Nextcloud. Here's the setup that I use in Nextcloud.

One of my users needed to use the forgot password feature on Nextcloud, and it allowed him to reset his password in a way that was compatible with iRedMail, too. This lets my iRedMail's MySQL server act as a central identity service. I don't use quota features much, but it looks like iRedMail and Nextcloud may have compatible quota features to allow me to set a single quota for a user, that would be enforced in both places.

This is a really great way to increase the value of my iRedMail server.

  1. Install the User SQL plugin like you would any other.[*/]

  2. Logged in as a Nextcloud admin, go to Settings.

  3. Choose SQL Backend.

  4. On the SQL backend settings page, under Database Connection set things this way:

    • SQL Driver = MySQL (Presumably you can also use PostgreSQL, but I haven't tested it)

    • Hostname = (your database server)

    • Database = vmail

    • Username = vmail

    • Password = your vmail password. Get it from /root/.my.cnf-vmail, for example.

  5. Under Options:

    • Tick Enable Display Name Change

    • Tick Allow Password Change

    • Hash Algorithm = SSHA512 (that's what I use, you have to pick something that works for you)

    • Email Sync = SQL Always Wins

    • Other options you can set as you like.

  6. Under User Table:

    • Table name = mailbox

    • Username = username

    • Email = username

    • Password = password

    • Display Name = name

    • Active = enablesmtp (if enablesmtp is set to 0, they won't have access to Nextcloud, either)

  7. Leave the Group Table and User Group Table empty.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: iRedmail + Nextcloud + MySQL identity integration

Hey pacohope, thank you so much for this guide on setting this up. I too am running Nextcloud along with my iRedMail instance.

I had a question. I currently have them separated with a couple of users, with the RainLoop webmail installed on Nextcloud set to use the users I have setup login information to automatically login to the mail server. With that of course their username and passwords are just set to the same as their inbox. Do you know if I was to enable this feature now, would this break the current users?

Again, thank you very much for this, this is huge.

3

Re: iRedmail + Nextcloud + MySQL identity integration

I went ahead and tested my theory, and it does not like it at all.

Quota, also, does not work. If you set it up to use the quota it reads the amounts incorrectly, changing it in either NC or iRedAdmin does not update after the initial pull and rewrites back to what it was before (Whether Default, Static or Query is set).

I tried to change a password in NC and it did not update in iRedAdmin, but this could have been because I was using the username I had already setup before to do it.

4

Re: iRedmail + Nextcloud + MySQL identity integration

wylel wrote:

Do you know if I was to enable this feature now, would this break the current users?

If you enable this now, every nextcloud user is either a local nextcloud-only user or a shared user. If the user currently has the same email address as a login on both places, I think you're fine. I think it means their iredmail password becomes their nextcloud password. Their app may or may not stop syncing until they update their nextcloud password in their app/laptop/etc.

I had a different problem. Originally my iredmail users had one set of user names and passwords and my nextcloud users had another. Moreover, my nextcloud users were simple usernames, not email addresses. To migrate from separate nextcloud identities, I had to do a bunch of things in the nextcloud MySQL tables and in the nextcloud filesystem. I only had 5 users at the time, so it was easy enough.

Since then, I've created more iredmail users and they just got nextcloud access as a side-effect.

5

Re: iRedmail + Nextcloud + MySQL identity integration

Wow, Great idea, Thank you

6

Re: iRedmail + Nextcloud + MySQL identity integration

I cannot connect iredmail with nextcloud. I use mysql. Pls help me. Iredmail working.

error: Error connecting to the database: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [2002] No route to host

7

Re: iRedmail + Nextcloud + MySQL identity integration

Hi,

Nice article, can this be done with OWNCLOUD?
Also what changed did you have to make to the nextvloud db for this to work?

8

Re: iRedmail + Nextcloud + MySQL identity integration

thienn458 wrote:

SQLSTATE[HY000] [2002] No route to host

I didn't see this before. Of course, this is not a place to get help debugging MySQL. However the error is self explanatory: your web server doesn't know how to reach your database server. What this probably means is that you made a mistake somewhere. E.g., typed the wrong IP address, misspelled the hostname, etc. "No route to host" is what you get when you try to connect to an IP address that doesn't exist.

9

Re: iRedmail + Nextcloud + MySQL identity integration

gpapaiko wrote:

can this be done with OWNCLOUD?
Also what changed did you have to make to the nextvloud db for this to work?

I don't think so. It looks like the Nextcloud plugin architecture is a bit more robust than Owncloud. I don't see a user SQL plugin for Owncloud the way I see it for Nextcloud. Unless you've really got some vested interest in Owncloud, Nextcloud is a major upgrade in all ways. And they support migration.

There was no change to the Nextcloud DB. This SQL plugin keeps it's own mapping. "user name is in this table, this column. Password is in this table, this column." It looks at the MySQL database that iRedMail uses. It doesn't modify the Nextcloud database.

10

Re: iRedmail + Nextcloud + MySQL identity integration

hi i saw your post on adding nextcloud to iredmail its a great idea, i tested with that plugin and followed the tutorial https://forum.iredmail.org/user42497.html stated, i got the users imported on the users tab on nextcloud but how do i get their accounts created in nextcloud? i'm i missing a step or something? the goal is to make it so every user on iredmail can use the same mail and password to connect to nextcloud.
i'm using deban 8 on a vm with nexcloud 13 and iredmail installed on it