Example #1
0
        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;
            }
        }