I was wondering if there was any simple way to authenticate Openfire users against my existing ASP.NET membership? I see that Openfire has a custom database integration guide here
but I don’t think that it supports my current method of password security. Apparently some of my members have type 1 and some have type 2 password security. I’m not sure how that happened, but since they are inconsistent, I can’t use one of Openfire’s preset password security options. I’d need to query against my database to figure out how the password is stored and then apply the correct method of password authentication based on the type. Any suggestions?
I was wondering if there was any simple way to authenticate Openfire users against
Share
So, it’s actually not that hard to get this to work. You need to create three new Java files, one for each of the following:
Implementing the admin provdier and the user provider is straightfoward, just follow the JDBC examples that are provided. One thing to note is that the IIS databse is keyed off of some GUID, and the actual user account fields (E-mail, name, etc) are in a different table, so you have to do a query to figure out the IIS ID, then use that to figure out the rest of the account fields, ie.
SELECT TOP 1 UserId FROM dbo.aspnet_Users WHERE LoweredUserName = ?Then to get the E-mail (after you have the IIS ID)
SELECT TOP 1 Email FROM dbo.aspnet_Membership WHERE UserId = ?Doing the actual authentication is very easy, just take the username given to you by openfire, clean it up (it’s sometimes user@host — the @host part is not really part of the username) and figure out the IIS ID based on the username you’re given.
Then you can do a query to figure out the password & password hash
SELECT TOP 1 Password, PasswordSalt FROM dbo.aspnet_Membership WHERE UserId = ?With that you have all you need to encrypt the password that’s given to you — here’s the algorithm:
Note — all of the utils are included with OpenFire (ie.
decodeHex(...),Base64...)Just compare the result of this function with the IIS database’s password field and you’ll be off and running.
Another thing to note with the Admin provider: the AdminManager that openfire uses caches the results. It looks like the results get cached when the system starts — so it’s not really possible to keep the list of admins in sync with IIS. I’m still mulling over that one to figure out what the best approach will be. I might just remove the caching all together (AdminManager just holds a list of admins in memory.)
Once you get everything setup, just change a few properties in the config for openfire to connect it to your solution, ex.
I added a few more properties for the IIS database username/password as well as some variables for what the name of my admin group is, etc. Just follow the JDBC examples and it’s very easy. Note that after you change the
provider.*properties in the openfire config you won’t be able to login with the default admin anymore — if something is messed up you’ll have to go back into the database and change the config (in thedbo.ofPropertytable of your openfire DB.)