其他分享
首页 > 其他分享> > coremailAPI邮箱用户的增改单点登录1

coremailAPI邮箱用户的增改单点登录1

作者:互联网

package coremailapi;

import tebie.applib.api.APIContext;
import tebie.applib.api.IClient;

import java.net.Socket;

public class CoremailApi {
    private APIContext ret;
    private IClient cli;

    private String providerId;
    private String orgId;
    private String userId;
    private String domainName;
    private String userEmail;
    private String serverip;

    private Socket socket = null;

    public CoremailApi(String providerId,String orgId,String userId,String domainName, String serverip){
        this.providerId=providerId;
        this.orgId=orgId;
        this.userId=userId;
        this.domainName=domainName;
        this.userEmail=userId + "@" + domainName;
        this.serverip = serverip;

        try{
            socket = new Socket(serverip, 6195);
            cli = APIContext.getClient(socket);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    //创建用户
    void createUser(){
        try {
            ret = cli.createUser(providerId, orgId,userId,"domain_name="+domainName+"&cos_id=1&user_status=0");
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    //修改用户密码
    void updateUser(String passwd){
        try{
            ret = cli.changeAttrs(userEmail, "true_name="+userId+"&password="+passwd);
            if (ret.getRetCode() == 0){
                System.out.println(userEmail + " 用户的密码已被修改");
            }else {
                System.out.println(userEmail + "用户密码修改失败");
                System.out.println("code: " + ret.getRetCode());
                System.out.println("Msg: " + ret.getErrorInfo());
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    // 用户单点登录
    void userLogin(){
        try{
            ret = cli.userLogin(userEmail);
            if (ret.getRetCode() == 0){
                String sid = ret.getResult();
                System.out.println(userEmail + " 的单点登录链接:");
                System.out.printf("http://%s/coremail/main.jsp?sid=%s\n",serverip,sid);
                System.out.printf("http://%s/webadmin/~%s/~/usr/index_usr.jsp\n",serverip,sid);

            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}


标签:增改,userEmail,coremailAPI,单点,String,userId,private,ret,out
来源: https://blog.51cto.com/11732619/2677444