+ Z_IdAuthentication *auth = NULL;
+ if (srw_pdu->username && srw_pdu->password)
+ {
+ yaz_log(YLOG_LOG, "username/password: %s/%s\n",
+ srw_pdu->username, srw_pdu->password);
+ auth = (Z_IdAuthentication *) odr_malloc(m_s2z_odr_init, sizeof(Z_IdAuthentication));
+ auth->which = Z_IdAuthentication_idPass;
+ auth->u.idPass = (Z_IdPass *) odr_malloc(m_s2z_odr_init, sizeof(Z_IdPass));
+ auth->u.idPass->groupId = NULL;
+ auth->u.idPass->password = odr_strdup(m_s2z_odr_init, srw_pdu->password);
+ auth->u.idPass->userId = odr_strdup(m_s2z_odr_init, srw_pdu->username);
+ }
+ else
+ {
+ if (*authorization_str)
+ {
+ yaz_log(YLOG_LOG, "authorization_str present: %s\n", authorization_str);
+ auth = (Z_IdAuthentication *) odr_malloc(m_s2z_odr_init, sizeof(Z_IdAuthentication));
+ auth->which = Z_IdAuthentication_idPass;
+ auth->u.idPass = (Z_IdPass *) odr_malloc(m_s2z_odr_init, sizeof(Z_IdPass));
+ auth->u.idPass->groupId = NULL;
+ char *p = strchr(authorization_str, ':');
+ if (p)
+ {
+ *p = '\0';
+ p++;
+ auth->u.idPass->password = odr_strdup(m_s2z_odr_init, p);
+ }
+ auth->u.idPass->userId = odr_strdup(m_s2z_odr_init, authorization_str);
+ }
+ else
+ {
+ // Use _client_ IP as shown in the log entries...!
+ yaz_log(YLOG_LOG, "No authorization_str present: use client IP: %s\n", m_peername);
+
+ auth = (Z_IdAuthentication *) odr_malloc(m_s2z_odr_init, sizeof(Z_IdAuthentication));
+ auth->which = Z_IdAuthentication_idPass;
+ auth->u.idPass = (Z_IdPass *) odr_malloc(m_s2z_odr_init, sizeof(Z_IdPass));
+ auth->u.idPass->groupId = NULL;
+ auth->u.idPass->password = NULL;
+ auth->u.idPass->userId = odr_strdup(m_s2z_odr_init, m_peername);
+ }
+ }
+