当前位置: 首页>>代码示例>>C#>>正文


C# LibraryChannel.SetUser方法代码示例

本文整理汇总了C#中LibraryChannel.SetUser方法的典型用法代码示例。如果您正苦于以下问题:C# LibraryChannel.SetUser方法的具体用法?C# LibraryChannel.SetUser怎么用?C# LibraryChannel.SetUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LibraryChannel的用法示例。


在下文中一共展示了LibraryChannel.SetUser方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateManageUser

        // 创建代理帐户
        int CreateManageUser(out string strError)
        {
            strError = "";
            if (this.textBox_dp2LibraryUrl.Text == "")
            {
                strError = "尚未指定dp2Library服务器URL";
                return -1;
            }

            if (this.textBox_manageUserName.Text == "")
            {
                strError = "尚未指定代理帐户的用户名";
                return -1;
            }

            if (this.textBox_manageUserName.Text == "reader"
                || this.textBox_manageUserName.Text == "public"
                || this.textBox_manageUserName.Text == "图书馆")
            {
                strError = "代理帐户的用户名不能为 'reader' 'public' '图书馆' 之一,因为这些都是 dp2Library 系统内具有特定用途的保留帐户名";
                return -1;
            }

            if (this.textBox_managePassword.Text != this.textBox_confirmManagePassword.Text)
            {
                strError = "代理帐 密码 和 再次输入密码 不一致。请重新输入。";
                return -1;
            }

            using (LibraryChannel channel = new LibraryChannel())
            {
                channel.Url = this.textBox_dp2LibraryUrl.Text;

                channel.BeforeLogin -= new BeforeLoginEventHandle(channel_BeforeLogin);
                channel.BeforeLogin += new BeforeLoginEventHandle(channel_BeforeLogin);

                strError = "请用超级用户身份登录,以便创建代理帐户。";
                int nRet = channel.DoNotLogin(ref strError);
                if (nRet == -1 || nRet == 0)
                {
                    strError = "以超级用户身份登录失败: " + strError;
                    return -1;
                }
                UserInfo user = new UserInfo();
                user.UserName = this.textBox_manageUserName.Text;
                user.Password = this.textBox_managePassword.Text;
                user.SetPassword = true;
                // default_opac_rights
                user.Rights = "getsystemparameter,getres,search,getbiblioinfo,setbiblioinfo,getreaderinfo,writeobject,getbibliosummary,listdbfroms,simulatereader,simulateworker"
                    + ",getiteminfo,getorderinfo,getissueinfo,getcommentinfo";  // 2016/1/27

                /*
    代理帐户:
    getsystemparameter
    getres
    search
    getbiblioinfo
    getreaderinfo
    writeobject * */

                long lRet = channel.SetUser(
        null,
        "new",
        user,
        out strError);
                if (lRet == -1)
                {
                    strError = "创建代理帐户时发生错误: " + strError;
                    return -1;
                }

                channel.Logout(out strError);
                return 0;
            }
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:76,代码来源:InstallOpacParamDlg.cs

示例2: ResetManageUserPassword

        // 重设置代理帐户密码
        int ResetManageUserPassword(out string strError)
        {
            strError = "";
            if (this.textBox_dp2LibraryUrl.Text == "")
            {
                strError = "尚未指定dp2Library服务器URL";
                return -1;
            }

            if (this.textBox_manageUserName.Text == "")
            {
                strError = "尚未指定代理帐户的用户名";
                return -1;
            }

            if (this.textBox_managePassword.Text != this.textBox_confirmManagePassword.Text)
            {
                strError = "代理帐户 密码 和 再次输入密码 不一致。请重新输入。";
                return -1;
            }

            using (LibraryChannel channel = new LibraryChannel())
            {
                channel.Url = this.textBox_dp2LibraryUrl.Text;

                channel.BeforeLogin -= new BeforeLoginEventHandle(channel_BeforeLogin);
                channel.BeforeLogin += new BeforeLoginEventHandle(channel_BeforeLogin);

                strError = "请用超级用户身份登录,以便重设代理帐户密码。";
                int nRet = channel.DoNotLogin(ref strError);
                if (nRet == -1 || nRet == 0)
                {
                    strError = "以超级用户身份登录失败: " + strError;
                    return -1;
                }

                if (StringUtil.IsInList("changeuserpassword", channel.Rights) == false)
                {
                    strError = "您所使用的超级用户 '" + this.SupervisorUserName + "' 不具备 changeuserpassword 权限,无法进行(为代理帐户 '" + this.textBox_manageUserName.Text + "' )重设密码的操作";
                    return -1;
                }

                UserInfo user = new UserInfo();
                user.UserName = this.textBox_manageUserName.Text;
                user.Password = this.textBox_managePassword.Text;

                long lRet = channel.SetUser(
                    null,
                    "resetpassword",
                    user,
                    out strError);
                if (lRet == -1)
                {
                    strError = "重设密码时发生错误: " + strError;
                    return -1;
                }

                channel.Logout(out strError);
                return 0;
            }
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:62,代码来源:InstallOpacParamDlg.cs

示例3: button_dp2library_changePassword_Click


//.........这里部分代码省略.........
                    goto ERROR1;
                }
                dp2Server server = this.MainForm.Servers.GetServerByName(this.LibraryServerName);
                if (server == null)
                {
                    strError = "服务器名为 '" + this.LibraryServerName + "' 的服务器不存在...";
                    goto ERROR1;
                }

                string strServerUrl = server.Url;

                this.Channel = this.Channels.GetChannel(strServerUrl);


                // 非强制修改密码,即本人修改
                if (this.checkBox_dp2library_force.Checked == false)
                {

                    // return:
                    //      -1  error
                    //      0   登录未成功
                    //      1   登录成功
                    lRet = Channel.Login(this.textBox_dp2library_userName.Text,
                        this.textBox_dp2library_oldPassword.Text,
                        "location=dp2Catalog,type=worker",
                        /*
                        "",
                        false,
                         * */
                        out strError);
                    if (lRet == -1)
                    {
                        goto ERROR1;
                    }

                    if (lRet == 0)
                    {
                        strError = "旧密码不正确";
                        goto ERROR1;
                    }

                    try
                    {

                        lRet = Channel.ChangeUserPassword(
                            stop,
                            this.textBox_dp2library_userName.Text,
                            this.textBox_dp2library_oldPassword.Text,
                            this.textBox_dp2library_newPassword.Text,
                            out strError);
                        if (lRet == -1)
                            goto ERROR1;
                    }
                    finally
                    {
                        string strError_1 = "";
                        Channel.Logout(out strError_1);
                    }
                }

                // 强制修改密码
                if (this.checkBox_dp2library_force.Checked == true)
                {
                    UserInfo info = new UserInfo();
                    info.UserName = this.textBox_dp2library_userName.Text;
                    info.Password = this.textBox_dp2library_newPassword.Text;
                    // 当action为"resetpassword"时,则info.ResetPassword状态不起作用,无论怎样都要修改密码。resetpassword并不修改其他信息,也就是说info中除了Password/UserName以外其他成员的值无效。
                    lRet = Channel.SetUser(
                        stop,
                        "resetpassword",
                        info,
                        out strError);
                    if (lRet == -1)
                        goto ERROR1;

                }


            }
            finally
            {
                this.EnableControls(true);

                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");
            }

            MessageBox.Show(this, "dp2library 用户 '" + this.textBox_dp2library_userName.Text + "' 密码已经被成功修改。");

            this.textBox_dp2library_userName.SelectAll();
            this.textBox_dp2library_userName.Focus();
            return;
        ERROR1:
            MessageBox.Show(this, strError);

            // 焦点重新定位到密码输入域
            this.textBox_dp2library_oldPassword.Focus();
            this.textBox_dp2library_oldPassword.SelectAll();
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:ChangePasswordForm.cs


注:本文中的LibraryChannel.SetUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。