Attention! The c2s_plainauthonly option is only available in svn, it is not in version 4.3.
[general] domains=mydomain.org c2s_plainauthonly=yes; force text password for LDAP auth [listener s2s] enable=yes type=s2s port=5269 [listener c2s] enable=yes type=c2s port=5222
[yate] certificate=yate.pem domains=mydomain.org
[general] user.auth=yes user.register=yes user.unregister=yes engine.timer=yes [default] account=yate [user.auth] query=SELECT password FROM users WHERE username='${username}' AND password IS NOT NULL AND password<>'' result=password [user.register] query=UPDATE users SET location='${data}', expires=CURRENT_TIMESTAMP + INTERVAL ${expires}+300 second WHERE username='${username}' [user.unregister] query=UPDATE users SET location=NULL,expires=NULL WHERE expires IS NOT NULL AND username='${username}' [engine.timer] query=UPDATE users SET location=NULL,expires=NULL WHERE expires IS NOT NULL AND expires<=CURRENT_TIMESTAMP
CREATE TABLE `offlinechat` ( `username` varchar(100) DEFAULT NULL, `xml` text, `time` int(11) NOT NULL, KEY `username` (`username`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE `roster` ( `username` varchar(100) DEFAULT NULL, `contact` varchar(100) DEFAULT NULL, `name` varchar(100) DEFAULT NULL, `groups` varchar(100) DEFAULT NULL, `subscription` varchar(100) DEFAULT NULL, UNIQUE KEY `uc` (`username`,`contact`), KEY `username` (`username`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE `users` ( `username` varchar(100) NOT NULL DEFAULT '', `password` varchar(100) DEFAULT NULL, `vcard` text, `location` varchar(100) DEFAULT NULL, `expires` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`username`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
[yate] database=yate user=yate password=yatepass
[general] account=yate [vcard] get=SELECT vcard FROM users WHERE username='${username}' set=UPDATE users SET vcard='${vcard}' WHERE username='${username}' [offline_chat] get=SELECT * FROM offlinechat WHERE username='${username}' ORDER BY time add=INSERT INTO offlinechat (username,xml,time) VALUES ('${username}', '${xml}', ${time}) clear_user=DELETE FROM offlinechat WHERE username='${username}'
[general] account=yate user_roster_load=SELECT users.username, roster.* FROM users LEFT OUTER JOIN roster ON users.username=roster.username WHERE users.username='${username}' user_roster_delete=DELETE FROM roster WHERE username='${username}' contact_load=SELECT * FROM roster WHERE username='${username}' AND contact='${contact}' contact_subscription_set=INSERT roster (username,contact,subscription) VALUES ('${username}','${contact}','${subscription}') ON DUPLICATE KEY UPDATE subscription='${subscription}' contact_set=INSERT roster (username,contact,name,groups) VALUES ('${username}','${contact}','${name}','${groups}') ON DUPLICATE KEY UPDATE name='${name}',groups='${groups}' contact_set_full=INSERT roster (username,contact,name,groups,subscription) VALUES ('${username}','${contact}','${name}','${groups}','${subscription}') ON DUPLICATE KEY UPDATE name='${name}',groups='${groups}',subscription='${subscription}' contact_delete=DELETE FROM roster WHERE username='${username}' AND contact='${contact}'
[user.register] query=INSERT users (username,location,expires) VALUES ('${username}','${data}',CURRENT_TIMESTAMP + INTERVAL ${expires}+300 second) ON DUPLICATE KEY UPDATE location='${data}', expires=CURRENT_TIMESTAMP + INTERVAL ${expires}+300 second
[general] scripts_dir=/etc/yate/ [scripts] jabber.php=
TLS_REQCERT never
#!/usr/bin/php -q <?php require_once("libyate.php"); $ad_host = 'ldaps://dc.mydomain.org'; $ad_domain = 'mydomain.org'; /* Always the first action to do */ Yate::Init(); /* Install a handler for the call routing message */ Yate::Install("user.auth",40); function ad_auth($user, $password) { global $ad_host, $ad_domain; $con = ldap_connect($ad_host); return ldap_bind($con, "$user@$ad_domain", $password) & true; } /* The main loop. We pick events and handle them */ for (;;) { $ev=Yate::GetEvent(); /* If Yate disconnected us then exit cleanly */ if ($ev === false) break; /* Empty events are normal in non-blocking operation. This is an opportunity to do idle tasks and check timers */ if ($ev === true) { // Yate::Output("PHP event: empty"); continue; } /* If we reached here we should have a valid object */ switch ($ev->type) { case "incoming": switch ($ev->name) { case "user.auth": if (!isset($ev->params["digest-uri"])) { $username = $ev->params["username"]; $username = substr($username,0,strpos($username,'@')); $password = isset($ev->params["response"]) ? $ev->params["response"] : $ev->params["password"]; $auth = ad_auth($username, $password); if ($auth) { $ev->retval = $password; $ev->handled = true; } } break; } $ev->Acknowledge(); break; case "installed": Yate::Output("PHP Installed: " . $ev->name); break; case "uninstalled": Yate::Output("PHP Uninstalled: " . $ev->name); break; default: Yate::Output("PHP Event: " . $ev->type); } } Yate::Output("PHP: bye!"); /* vi: set ts=8 sw=4 sts=4 noet: */ ?>
Source: https://habr.com/ru/post/166235/