Exemple #1
0
        public Result ResetPassword(AuthInfo authInfo, string account, string password)
        {
            try
            {
                YZService.AuthSystem(authInfo);
                YZAuthHelper.SetAuthCookie(authInfo.RealLoginAccount);

                using (BPMConnection cn = new BPMConnection())
                {
                    cn.WebOpen();

                    string           oupath;
                    MemberCollection members = OrgSvr.GetUserPositions(cn, account);
                    if (members.Count == 0)
                    {
                        oupath = cn.GetRootOUs()[0].FullName;
                    }
                    else
                    {
                        oupath = members[0].GetParentOU(cn).FullName;
                    }

                    BPM.Client.User.ResetPassword(cn, oupath, account, password);
                }

                return(Result.SuccessResult);
            }
            catch (Exception e)
            {
                return(Result.FromException(e));
            }
        }
Exemple #2
0
        public Result UpdateUser(AuthInfo authInfo, UserInfo userInfo, string updateFieldName)
        {
            try
            {
                YZService.AuthSystem(authInfo);
                YZAuthHelper.SetAuthCookie(authInfo.RealLoginAccount);

                //传入值检查
                if (String.Compare(updateFieldName, "Password") == 0)
                {
                    throw new Exception(String.Format("属性不支持以更新方式修改:{0}", updateFieldName));
                }

                using (BPMConnection cn = new BPMConnection())
                {
                    cn.WebOpen();

                    //获得用户原始信息
                    User user = new User();
                    user.Open(cn, userInfo.Account);

                    //粘合新属性
                    PropertyInfo tagProp = typeof(User).GetProperty(updateFieldName);
                    FieldInfo    srcProp = typeof(UserInfo).GetField(updateFieldName);
                    if (tagProp == null || srcProp == null)
                    {
                        throw new Exception(String.Format("无效的属性:{0}", updateFieldName));
                    }

                    tagProp.SetValue(user, srcProp.GetValue(userInfo), null);

                    //执行更新
                    BPM.Client.User.Update(cn, user.Account, user);
                }

                return(Result.SuccessResult);
            }
            catch (Exception e)
            {
                return(Result.FromException(e));
            }
        }
Exemple #3
0
        public Result AddUser(AuthInfo authInfo, UserInfo userInfo)
        {
            try
            {
                YZService.AuthSystem(authInfo);
                YZAuthHelper.SetAuthCookie(authInfo.RealLoginAccount);

                using (BPMConnection cn = new BPMConnection())
                {
                    cn.WebOpen();
                    OU.AddMember(cn, YZService.LDAPOU2BPMOUPath(userInfo.LDAPOU), null, userInfo.Member, userInfo.User, null, null, null);
                }

                return(Result.SuccessResult);
            }
            catch (Exception e)
            {
                return(Result.FromException(e));
            }
        }