Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Administrators

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-11-2007, 04:26 AM
Junior Member
 
Posts: 9
Default A quick and dirty solution to sync samba passwords

Scenario:

*) Zimbra 4.5 running on CentOS, configured with internal authentication
*) zimbra_posixaccount and zimbra_samba Admin Extensions installed
*) Samba PDC on another machine using the zimbra ldap backend for users and groups
*) No time to study and try how to extend UI using APIs, Zimlets and so on
*) Need to solve the full sso issue with zimbra and samba


Quick and dirty solution:

1) download, make and copy mkntpwd into /opt/zimbra/bin

2) download zimbra 4.5 sources

3) read Zimbra Development with Eclipse

4) modify LdapProvisioning.java in the com.zimbra.cs.account.ldap package writing a new setPassword(Account acct, String newPassword, boolean enforcePolicy) method and comment out the old one:

void setPassword(Account acct, String newPassword, boolean enforcePolicy) throws ServiceException {

if (enforcePolicy) {
checkPasswordStrength(newPassword, acct, null, null);
int minAge = acct.getIntAttr(Provisioning.A_zimbraPasswordMinAg e, 0);
if (minAge > 0) {
Date lastChange = acct.getGeneralizedTimeAttr(Provisioning.A_zimbraP asswordModifiedTime, null);
if (lastChange != null) {
long last = lastChange.getTime();
long curr = System.currentTimeMillis();
if ((last+(ONE_DAY_IN_MILLIS * minAge)) > curr)
throw AccountServiceException.PASSWORD_CHANGE_TOO_SOON() ;
}
}

}

Map<String, Object> attrs = new HashMap<String, Object>();

int enforceHistory = acct.getIntAttr(Provisioning.A_zimbraPasswordEnfor ceHistory, 0);
if (enforceHistory > 0) {
String[] newHistory = updateHistory(
acct.getMultiAttr(Provisioning.A_zimbraPasswordHis tory),
acct.getAttr(Provisioning.A_userPassword),
enforceHistory);
attrs.put(Provisioning.A_zimbraPasswordHistory, newHistory);
checkHistory(newPassword, newHistory);
}

String encodedPassword = LdapUtil.generateSSHA(newPassword, null);

String lmPassword = "";
try {
Process p1 = Runtime.getRuntime().exec("/opt/zimbra/bin/mkntpwd -L " + newPassword);
BufferedReader bf1=new BufferedReader(new InputStreamReader(p1.getInputStream()));
lmPassword = bf1.readLine();
} catch (IOException ioe) {
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] {"cmd", "LdapProvisioning.SetPassword","lmPassword", ioe.getMessage()}));
}

String ntPassword = "";
try {
Process p2 = Runtime.getRuntime().exec("/opt/zimbra/bin/mkntpwd -N " + newPassword);
BufferedReader bf2=new BufferedReader(new InputStreamReader(p2.getInputStream()));
ntPassword = bf2.readLine();
} catch (IOException ioe) {
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] {"cmd", "LdapProvisioning.SetPassword","ntPassword", ioe.getMessage()}));
}

boolean mustChange = acct.getBooleanAttr(Provisioning.A_zimbraPasswordM ustChange, false);
// unset it so it doesn't take up space...
if (mustChange)
attrs.put(Provisioning.A_zimbraPasswordMustChange, "");

attrs.put(Provisioning.A_userPassword, encodedPassword);
attrs.put(Provisioning.A_zimbraPasswordModifiedTim e, DateUtil.toGeneralizedTime(new Date()));

attrs.put("sambaLMPassword", lmPassword);
attrs.put("sambaNTPassword", ntPassword);

ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] {"cmd", "LdapProvisioning.SetPassword","lmPassword", lmPassword}));
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] {"cmd", "LdapProvisioning.SetPassword","ntPassword", ntPassword}));

modifyAttrs(acct, attrs);
}


5) rebuild zimbrastore.jar

6) zmcontrol stop

7) copy the new zimbrastore.jar into /opt/zimbra/lib/jars/, into /opt/zimbra/tomcat/webapps/zimbra/WEB-INF/lib/ and into /opt/zimbra/tomcat/webapps/service/WEB-INF/lib/ (make backup copy first!)

8) zmcontrol start

9) log in as admin and change a user password (and, if you want, set also the "must change password" checkbox)

10) in /opt/zimbra/log/audit.log you should note two lines with the NT and LM password hashes

11) open a samba share with the new credentials

It works for me.

Regards,
Antonio
Reply With Quote
  #2 (permalink)  
Old 06-11-2007, 04:32 AM
Junior Member
 
Posts: 9
Default Addendum

Adds the following imports in LdapProvisioning.java:


import java.lang.Process;
import java.lang.Runtime;
import java.io.InputStreamReader;
import java.io.BufferedReader;
Reply With Quote
  #3 (permalink)  
Old 11-07-2007, 04:02 PM
Member
 
Posts: 11
Default zimbrastore.jar

Hi,

Sorry, but i dont have experience compiling this "things", you can sendme you zimbrastore.jar ?


Thks,

Rafael Carvalho
Reply With Quote
  #4 (permalink)  
Old 11-08-2007, 12:29 PM
Zimbra Employee
 
Posts: 127
Default

This is a great post, thank you Amessina! Guys, vote for this bug Bug 17321 - Support change password listeners in provisioning and support Samba change password in the samba admin extension in order to get the support for this natively in Zimbra.
__________________
Bugzilla - Wiki - Downloads - Before posting... Search!
P.S.: don't forget to vote on this bug
add Samba LDAP entries to Exchange Migration Tool
Reply With Quote
  #5 (permalink)  
Old 11-09-2007, 02:35 AM
Junior Member
 
Posts: 9
Default

I'll going to publish a new post soon, with zimbrastore.jar attached
__________________
Antonio Messina
RHCE5, OCP10g

iKnow di Messina Antonio
Campobello di Mazara, Italy

http://www.iknowconsulting.it
Reply With Quote
  #6 (permalink)  
Old 11-09-2007, 02:36 AM
Junior Member
 
Posts: 9
Default

Thanks a lot Greg
__________________
Antonio Messina
RHCE5, OCP10g

iKnow di Messina Antonio
Campobello di Mazara, Italy

http://www.iknowconsulting.it

Last edited by amessina; 11-09-2007 at 02:39 AM..
Reply With Quote
  #7 (permalink)  
Old 11-09-2007, 04:23 AM
Member
 
Posts: 11
Default

Quote:
Originally Posted by amessina View Post
I'll going to publish a new post soon, with zimbrastore.jar attached
Thanks friends!!!
Reply With Quote
  #8 (permalink)  
Old 11-14-2007, 02:50 AM
Junior Member
 
Posts: 9
Default mkntpwd.tar.gz and zimbrastore.jar

I can't attach zimbrastore.jar 'cause is too big

You can download the required files using the following links:

http://www.orcom.it/zimbra/zimbrastore.jar
http://www.orcom.it/zimbra/mkntpwd.tar.gz

Re-read my first post for installation.

Regards
__________________
Antonio Messina
RHCE5, OCP10g

iKnow di Messina Antonio
Campobello di Mazara, Italy

http://www.iknowconsulting.it
Reply With Quote
  #9 (permalink)  
Old 11-15-2007, 02:54 PM
Member
 
Posts: 11
Default Thanks!!!

Thanks Antonio...
Thanks so much!!!

Rafael.
Reply With Quote
  #10 (permalink)  
Old 11-21-2007, 06:11 PM
Active Member
 
Posts: 38
Default Fixed for 5.0?

Is this issue fixed for 5.0?
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.