openfire整合已有用户数据库(在logs里出现问题:

Property 'jdbcProvider.connectionString' as specified in openfire.xml differs from what is stored in the database. Please make property changes in the database instead of openfire.xml.)http://lishao378.blog.sohu.com/146785554.html

 

首先看下测试数据库结构和内容:

mysql> use test;
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| user           |
+----------------+
1 row in set (0.00 sec)

mysql> select * from user;
+-----+-------+----------------------------------+-----------------+
| uid | uname | upass                            | email           |
+-----+-------+----------------------------------+-----------------+
|   1 | admin | admin                            | admin@localhost |
|   2 | test  | 5c177f35077e9e0a4a5f7cb4dbc96937 | test@localhost  |
+-----+-------+----------------------------------+-----------------+
2 rows in set (0.00 sec)

其中:admin密码是明文,test密码是字符串phpcms经md5加密后的密文。

按照官方在《Custom Database Integration Guide》中给出的示例,结合所建立的测试数据库在conf/openfire.xml中加入了以下代码:
  <provider>
    <auth>
      <className>org.jivesoftware.openfire.auth.JDBCAuthProvider</className>
    </auth>
    <user>
      <className>org.jivesoftware.openfire.user.JDBCUserProvider</className>
    </user>
  </provider>
  <jdbcAuthProvider>
     <passwordSQL>SELECT upass FROM user WHERE uname=?</passwordSQL>
     <passwordType>plain</passwordType>
  </jdbcAuthProvider>
  <jdbcUserProvider>
     <loadUserSQL>SELECT uname,email FROM user WHERE uname=?</loadUserSQL>
     <userCountSQL>SELECT COUNT(*) FROM user</userCountSQL>
     <allUsersSQL>SELECT uname FROM user</allUsersSQL>
     <searchSQL>SELECT uname FROM user WHERE</searchSQL>
     <usernameField>uname</usernameField>
     <nameField>uname</nameField>
     <emailField>email</emailField>
  </jdbcUserProvider>
但事实证明是不正确的。当重启服务端后,logs/warn.log给出了以下出错警告:
2010.03.23 23:39:44 Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.
2010.03.23 23:39:44 Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.
2010.03.23 23:42:41 Property 'provider.auth.className' as specified in openfire.xml differs from what is stored in the database.  Please make property changes in the database instead of openfire.xml.
2010.03.23 23:42:41 Property 'provider.user.className' as specified in openfire.xml differs from what is stored in the database.  Please make property changes in the database instead of openfire.xml.
可见,官方所说通过修改openfire.xml这个配置文件进行整合是不正确的。

经测试,在mysql中执行以下代码,可以有效进行集成:
;//-----------------------------------------------------------------------------------------------------------
UPDATE `openfire`.`ofProperty` SET propValue='org.jivesoftware.openfire.user.JDBCUserProvider' WHERE name='provider.user.className';
UPDATE `openfire`.`ofProperty` SET propValue='org.jivesoftware.openfire.auth.JDBCAuthProvider' WHERE name='provider.auth.className';
INSERT INTO `openfire`.`ofProperty` VALUES  ('jdbcProvider.driver','com.mysql.jdbc.Driver'),
('jdbcProvider.connectionString','jdbc:mysql://localhost:3306/test?user=admin&password=admin'),
('admin.authorizedJIDs','admin@localhost,test@localhost'),
('jdbcAuthProvider.passwordSQL','SELECT upass FROM user WHERE uname=?'),
('jdbcAuthProvider.passwordType','plain'),
('jdbcUserProvider.loadUserSQL','SELECT uname,email FROM user WHERE uname=?'),
('jdbcUserProvider.userCountSQL','SELECT COUNT(*) FROM user'),
('jdbcUserProvider.allUsersSQL','SELECT uname FROM user'),
('jdbcUserProvider.searchSQL','SELECT uname FROM user WHERE'),
('jdbcUserProvider.usernameField','uname'),
('jdbcUserProvider.nameField','uname'),
('jdbcUserProvider.emailField','email');
;//-----------------------------------------------------------------------------------------------------------
若要继续整合用户组等信息,可以参考《Custom Database Integration Guide》,把相关属性添加到ofProperty数据表中。

你可能感兴趣的:(openfire)