For an Alfresco 3.1sp1 system, use the following instructions:node
1) Run the following commands and check you have only one row in the output:app
SELECT anp1.node_id, anp1.qname_id, anp1.string_value FROM alf_node_properties anp1 INNER JOIN alf_qname aq1 ON aq1.id = anp1.qname_id INNER JOIN alf_node_properties anp2 ON anp2.node_id = anp1.node_id INNER JOIN alf_qname aq2 ON aq2.id = anp2.qname_id WHERE aq1.local_name = 'password' AND aq2.local_name = 'username' AND anp2.string_value = 'admin'
It should output the current md4 hashed password for the 'admin' user. An example output is:ide
+---------+----------+----------------------------------+ | node_id | qname_id | string_value | +---------+----------+----------------------------------+ | 4 | 10 | 209c6174da490caeb422f3fa5a7ae634 | +---------+----------+----------------------------------+ 1 row in set (0.00 sec)
2) If you get only one row, then update the table:ui
UPDATE alf_node_properties SET string_value='209c6174da490caeb422f3fa5a7ae634' WHERE node_id=THENODEIDABOVE and qname_id=THEQNAMEVALUEABOVE
Where you need to replace THENODEIDABOVE and THEQNAMEVALUEABOVE with the results from step 1), in this example 4 and 10 respectively.this
Note: Please use caution when running this SQL, and ensure that you have the appropriate AND conditions in the UPDATE query.加密
For Alfresco 1.4, use the following instructions:spa
UPDATE alf_node_properties SET string_value = '<MD4 hash here>' WHERE qname = '{http://www.alfresco.org/model/user/1.0}password' AND node_id in ( SELECT node_id FROM alf_node_properties WHERE qname = '{http://www.alfresco.org/model/user/1.0}username' AND string_value = 'admin' );
209c6174da490caeb422f3fa5a7ae634
0cb6948805f797bf2a82807973b89537
For Alfresco version 1.3, use the following instructions:code
You can use this to get the hash for current admin password:get
select string_value from alf_node_properties p, alf_namespace ns, alf_qname q where p.qname_id = q.id and q.ns_id = ns.id and ns.uri = 'http://www.alfresco.org/model/user/1.0' and q.local_name = 'password' AND node_id in ( SELECT node_id FROM alf_node_properties p, alf_namespace ns, alf_qname q WHERE p.qname_id = q.id and q.ns_id = ns.id and ns.uri = 'http://www.alfresco.org/model/user/1.0' and q.local_name = 'username' AND string_value = 'admin' );
And, you can use this to set the password:input
UPDATE alf_node_properties p SET string_value = '<MD4 hash here>' WHERE p.qname_id = (select q.id from alf_qname q, alf_namespace ns where q.ns_id = ns.id and ns.uri = 'http://www.alfresco.org/model/user/1.0' and q.local_name = 'password') AND node_id in ( SELECT node_id FROM alf_node_properties p, alf_namespace ns, alf_qname q WHERE p.qname_id = q.id and q.ns_id = ns.id and ns.uri = 'http://www.alfresco.org/model/user/1.0' and q.local_name = 'username' AND string_value = 'admin' );
For Alfresco versions lower than 1.3, set the password in the database using the MD4 hash. For example:
UPDATE node_properties SET string_value = '<MD4 hash here>' WHERE qname = '{http://www.alfresco.org/model/user/1.0}password' AND guid = ( SELECT guid FROM node_properties WHERE qname = '{http://www.alfresco.org/model/user/1.0}username' AND string_value = 'admin' );
The following class will allow the generation of the correct MD4 hash.
You will need the following jars:
public class MD4HashGenerator { static { try { MessageDigest.getInstance("MD4"); } catch (NoSuchAlgorithmException e) { Security.addProvider(new CryptixCrypto()); } } public MD4HashGenerator() { super(); } /** * @param args */ public static void main(String[] args) { System.out.println("Hash: " + new String(Hex.encodeHex(md4(args[0])))); } private static byte[] md4(String input) { try { MessageDigest digester = MessageDigest.getInstance("MD4"); return digester.digest(input.getBytes("UnicodeLittleUnmarked")); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e.getMessage(), e); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e.getMessage(), e); } } }
"admin"對應的MD4值爲「209c6174da490caeb422f3fa5a7ae634」