コード例 #1
0
ファイル: UserBLL.cs プロジェクト: gcode-mirror/chafam
        public bool CreateUser(Entities.User user, out string message)
        {
            try
            {
                AdamConnetion.AdamServer adamServer = new CAFAM.WebPortal.AdamConnetion.AdamServer();

                adamServer.ServerIP = ConfigurationSettings.AppSettings["ADAMServerIP"];
                adamServer.ServerPort = int.Parse(ConfigurationSettings.AppSettings["ADAMServerPort"]);
                adamServer.UsersDistinguishedName = ConfigurationSettings.AppSettings["ADAMUsersDistinguishedName"];
                adamServer.UserNameCredential = ConfigurationSettings.AppSettings["ADAMUserCredential"];
                adamServer.PasswordCredential = ConfigurationSettings.AppSettings["ADAMPasswordCredential"];
                adamServer.DomainCredential = ConfigurationSettings.AppSettings["ADAMDomainCredential"];

                DAO.UserDAO userDAO = new CAFAM.WebPortal.DAO.UserDAO(Web);

                if (System.DirectoryServices.Protocols.ResultCode.EntryAlreadyExists == userDAO.CreateUserAdam(user, adamServer))
                {
                    message = "El nombre de usuario seleccionado ya existe en el sistema, por favor ingrese uno nuevo. ";
                    return false;
                }
                else
                {
                    string group = string.Empty;
                    switch (user.UserType)
                    {
                        case CAFAM.WebPortal.Entities.EnumUserType.Afiliado:
                            group = ConfigurationSettings.AppSettings["ADAMAfiliadosMemberGroup"];
                            break;
                        case CAFAM.WebPortal.Entities.EnumUserType.No_Afiliado:
                            group = ConfigurationSettings.AppSettings["ADAMNoAfiliadosMemberGroup"];
                            break;
                        case CAFAM.WebPortal.Entities.EnumUserType.Empresa:
                            group = ConfigurationSettings.AppSettings["ADAMEmpresasMemberGroup"];
                            break;
                    }
                    userDAO.AddUserToAdamGroup(user, adamServer, group);
                    userDAO.AddUserToAdamGroup(user, adamServer, ConfigurationSettings.AppSettings["ADAMBaseMemberGroup"]);
                    userDAO.CreateUser(user);
                    message = string.Empty;

                    if (user.UserType != CAFAM.WebPortal.Entities.EnumUserType.Empresa)
                    {
                        System.Web.Security.FormsAuthentication.SetAuthCookie(user.UserNameWithoutMembership, true);
                    }

                    return true;
                }
            }
            catch (Exception ex)
            {
                AdamConnetion.AdamServer adamServer = new CAFAM.WebPortal.AdamConnetion.AdamServer();

                adamServer.ServerIP = ConfigurationSettings.AppSettings["ADAMServerIP"];
                adamServer.ServerPort = int.Parse(ConfigurationSettings.AppSettings["ADAMServerPort"]);
                adamServer.UsersDistinguishedName = ConfigurationSettings.AppSettings["ADAMUsersDistinguishedName"];
                adamServer.UserNameCredential = ConfigurationSettings.AppSettings["ADAMUserCredential"];
                adamServer.PasswordCredential = ConfigurationSettings.AppSettings["ADAMPasswordCredential"];
                adamServer.DomainCredential = ConfigurationSettings.AppSettings["ADAMDomainCredential"];

                 DAO.UserDAO userDAO = new CAFAM.WebPortal.DAO.UserDAO(Web);

                if(userDAO.UserExistAdam(adamServer, user))
                {
                    userDAO.DeleteUserAdam(user.UserNameWithoutMembership, adamServer);
                }

                throw ex;
            }
        }
コード例 #2
0
ファイル: UserBLL.cs プロジェクト: gcode-mirror/chafam
        public void DeleteUser(string profile)
        {
            Entities.User user = null;
            try
            {
                AdamConnetion.AdamServer adamServer = new CAFAM.WebPortal.AdamConnetion.AdamServer();

                adamServer.ServerIP = ConfigurationSettings.AppSettings["ADAMServerIP"];
                adamServer.ServerPort = int.Parse(ConfigurationSettings.AppSettings["ADAMServerPort"]);
                adamServer.UsersDistinguishedName = ConfigurationSettings.AppSettings["ADAMUsersDistinguishedName"];
                adamServer.UserNameCredential = ConfigurationSettings.AppSettings["ADAMUserCredential"];
                adamServer.PasswordCredential = ConfigurationSettings.AppSettings["ADAMPasswordCredential"];
                adamServer.DomainCredential = ConfigurationSettings.AppSettings["ADAMDomainCredential"];

                DAO.UserDAO userDAO = new CAFAM.WebPortal.DAO.UserDAO(Web);

                user = userDAO.GetUser(profile);

                userDAO.DeleteUser(profile);

                string profileADAM = profile.Substring(profile.IndexOf(":") + 1);

                userDAO.DeleteUserAdam(profileADAM, adamServer);
            }
            catch (Exception ex)
            {
                AdamConnetion.AdamServer adamServer = new CAFAM.WebPortal.AdamConnetion.AdamServer();

                adamServer.ServerIP = ConfigurationSettings.AppSettings["ADAMServerIP"];
                adamServer.ServerPort = int.Parse(ConfigurationSettings.AppSettings["ADAMServerPort"]);
                adamServer.UsersDistinguishedName = ConfigurationSettings.AppSettings["ADAMUsersDistinguishedName"];
                adamServer.UserNameCredential = ConfigurationSettings.AppSettings["ADAMUserCredential"];
                adamServer.PasswordCredential = ConfigurationSettings.AppSettings["ADAMPasswordCredential"];
                adamServer.DomainCredential = ConfigurationSettings.AppSettings["ADAMDomainCredential"];

                string profileADAM = profile.Substring(profile.IndexOf(":") + 1);

                DAO.UserDAO userDAO = new CAFAM.WebPortal.DAO.UserDAO(Web);

                if (!userDAO.UserExistSP(profile) && userDAO.UserExistAdam(adamServer, user))
                {
                    userDAO.CreateUser(user);
                }

                throw ex;
            }
        }