Esempio n. 1
0
        /// <summary>
        /// Ensures configuration is valid to proceed
        /// </summary>
        /// <returns></returns>
        public virtual ConfigStatus ValidatePrerequisite()
        {
            Status = ConfigStatus.AllGood;
            if (PersistedObject == null)
            {
                Status |= ConfigStatus.PersistedObjectNotFound;
            }
            if (CurrentTrustedLoginProvider == null)
            {
                CurrentTrustedLoginProvider = LDAPCP.GetSPTrustAssociatedWithCP(LDAPCP._ProviderInternalName);
                if (CurrentTrustedLoginProvider == null)
                {
                    Status |= ConfigStatus.NoSPTrustAssociation;
                }
            }
            if (IdentityClaim == null && Status == ConfigStatus.AllGood)
            {
                IdentityClaim = this.IdentityClaim = PersistedObject.AttributesListProp.Find(x => String.Equals(CurrentTrustedLoginProvider.IdentityClaimTypeInformation.MappedClaimType, x.ClaimType, StringComparison.InvariantCultureIgnoreCase) && !x.CreateAsIdentityClaim);
                if (IdentityClaim == null)
                {
                    Status |= ConfigStatus.NoIdentityClaimType;
                }
            }
            if (PersistedObjectVersion != PersistedObject.Version)
            {
                Status |= ConfigStatus.PersistedObjectStale;
            }

            if (Status != ConfigStatus.AllGood)
            {
                LdapcpLogging.Log(String.Format(MostImportantError), TraceSeverity.High, EventSeverity.Information, LdapcpLogging.Categories.Configuration);
            }
            return(Status);
        }
Esempio n. 2
0
        protected void grdLDAPConnections_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if (ValidatePrerequisite() != ConfigStatus.AllGood)
            {
                return;
            }
            if (PersistedObject.LDAPConnectionsProp == null)
            {
                return;
            }
            GridViewRow rowToDelete = grdLDAPConnections.Rows[e.RowIndex];

            Guid Id = new Guid(rowToDelete.Cells[0].Text);

            PersistedObject.LDAPConnectionsProp.Remove(PersistedObject.LDAPConnectionsProp.Find(x => x.Id == Id));

            // Update object in database
            CommitChanges();
            LdapcpLogging.Log(
                String.Format("Removed a LDAP connection in PersistedObject {0}", Constants.LDAPCPCONFIG_NAME),
                TraceSeverity.Medium,
                EventSeverity.Information,
                LdapcpLogging.Categories.Configuration);

            InitializeAugmentation();
            PopulateLdapConnectionGrid();
        }
Esempio n. 3
0
 public virtual void CommitChanges()
 {
     PersistedObject.Update();
     PersistedObjectVersion = PersistedObject.Version;
     LdapcpLogging.Log(
         String.Format("Updated PersistedObject {0} to version {1}", PersistedObject.DisplayName, PersistedObject.Version),
         TraceSeverity.Medium,
         EventSeverity.Information,
         LdapcpLogging.Categories.Configuration);
 }
Esempio n. 4
0
        /// <summary>
        /// Add new LDAP connection to collection in persisted object
        /// </summary>
        void AddLdapConnection()
        {
            if (ValidatePrerequisite() != ConfigStatus.AllGood)
            {
                return;
            }

            if (this.RbUseCustomConnection.Checked && (this.TxtLdapConnectionString.Text == String.Empty || this.TxtLdapUsername.Text == String.Empty || this.TxtLdapPassword.Text == String.Empty))
            {
                this.LabelErrorTestLdapConnection.Text = TextErrorLDAPFieldsMissing;
                return;
            }

            if (this.RbUseServerDomain.Checked)
            {
                PersistedObject.LDAPConnectionsProp.Add(new LDAPConnection {
                    UserServerDirectoryEntry = true
                });
            }
            else
            {
                AuthenticationTypes authNType = GetSelectedAuthenticationTypes(true);
                PersistedObject.LDAPConnectionsProp.Add(
                    new LDAPConnection
                {
                    UserServerDirectoryEntry = false,
                    Path                = this.TxtLdapConnectionString.Text,
                    Username            = this.TxtLdapUsername.Text,
                    Password            = this.TxtLdapPassword.Text,
                    AuthenticationTypes = authNType,
                }
                    );
            }

            // Update object in database
            CommitChanges();
            LdapcpLogging.Log(
                String.Format("Added a new LDAP connection in PersistedObject {0}", Constants.LDAPCPCONFIG_NAME),
                TraceSeverity.Medium,
                EventSeverity.Information,
                LdapcpLogging.Categories.Configuration);

            PopulateLdapConnectionGrid();
            InitializeAugmentation();
            ViewState["LDAPpwd"] = String.Empty;
            TxtLdapPassword.Attributes.Remove("value");
            this.TxtLdapUsername.Text         = this.TxtLdapPassword.Text = String.Empty;
            this.TxtLdapConnectionString.Text = "LDAP://";
        }