Enable Plain Text Password

本文介绍如何在Windows XP、Vista及7系统中手动配置Samba服务所需的注册表键值及安全策略设置,以便通过明文密码连接第三方SMB服务器。

Windows XP, Windows Vista Edition and Windows 7

Plain text password is necessary for Windows XP and Windows Vista when you require ENCS services through Samba. A typical example is to hook ENCS printers to a user-managed machine. To do it (Windows XP Home or Windows Vista Home Edition), you can manually run the registry key "xp.reg".

  1. Right click on "xp.reg", select "save link as" to save the file.
  2. Since the file will be saved as text file so right click and rename it as “xp.reg”
  3. Double click the saved file to change the registry key.
  4. Reboot the machine to have the change effective.

Manual Configuration:

  1. Click on Start>Programs>Administrative Tools

NOTE:

For Windows XP:
We have seen some Windows XP systems that did not have Administrative Tools on the Programs menu. If it is not there go to
Start -> Settings -> Control Panel
and select Administrative Tools.

For Windows Vista & Windows 7:
If you view Control Panel by 'Catagory', then go to
System & Security -> Administrative Tools

Note: If the above option does not show, Registry key can also be manually modified by:

- Browse to HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/LanmanWorkStation/parameters]
- Set "EnablePlainTextPassword"=dword:00000001

  1. On the Administrative Tools folder, double-click Local Security Policy.
  2. On the Security Setting folder, click the plus sign next to Local Policies to expand it.
  3. Double-click Security Options.
  4. Scroll down to near the bottom of the list.
  5. Double-click on 'Microsoft network client: Send unencrypted passwords to connect to third-party SMB servers'
  6. Click the Enabled radio button.
  7. Click OK.
  8. Close the Local Security Settings Window.
  9. Re-boot you Windows XP.
`SSLException: Unrecognized SSL message, plaintext connection` 这个异常通常发生在客户端尝试通过SSL/TLS加密的通道发送数据时,但服务器端却以明文方式进行监听和接受数据,导致服务器无法识别或理解客户端发送的经过SSL加密的消息[^2]。以下是几种可能的解决办法: #### 1. 确认服务器是否支持SSL 要保证邮件服务器支持SSL连接。有些服务器可能只支持明文连接或者STARTTLS。可以查看邮件服务器的文档或者联系管理员来确认。 #### 2. 调整邮件配置 如果服务器支持STARTTLS,可在Java代码里使用STARTTLS而非直接的SSL连接。以下是一个使用JavaMail API的示例: ```java import javax.mail.*; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import java.util.Properties; public class SendEmailWithStartTLS { public static void main(String[] args) { // 配置邮件服务器属性 Properties properties = new Properties(); properties.put("mail.smtp.auth", "true"); properties.put("mail.smtp.starttls.enable", "true"); properties.put("mail.smtp.host", "smtp.example.com"); properties.put("mail.smtp.port", "587"); // 创建会话 Session session = Session.getInstance(properties, new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("your_email@example.com", "your_password"); } }); try { // 创建邮件消息 Message message = new MimeMessage(session); message.setFrom(new InternetAddress("your_email@example.com")); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("recipient_email@example.com")); message.setSubject("Test Email"); message.setText("This is a test email sent using JavaMail API."); // 发送邮件 Transport.send(message); System.out.println("Email sent successfully."); } catch (MessagingException e) { e.printStackTrace(); } } } ``` #### 3. 检查端口配置 要确保使用的端口是正确的。通常,SSL连接使用端口465,而STARTTLS使用端口587。 #### 4. 禁用SSL验证(不推荐用于生产环境) 在测试环境下,可以暂时禁用SSL验证来排查问题: ```java import javax.net.ssl.*; import java.security.cert.X509Certificate; public class DisableSSLVerification { public static void disableSSLVerification() { try { // 创建一个信任所有证书的TrustManager TrustManager[] trustAllCerts = new TrustManager[]{ new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(X509Certificate[] certs, String authType) { } public void checkServerTrusted(X509Certificate[] certs, String authType) { } } }; // 安装信任管理器 SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); // 创建一个允许所有主机名的HostnameVerifier HostnameVerifier allHostsValid = new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } }; // 安装主机名验证器 HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid); } catch (Exception e) { e.printStackTrace(); } } } ``` 在发送邮件之前调用 `DisableSSLVerification.disableSSLVerification()` 方法。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值