Skip to content

Commit

Permalink
update GetDefaultSettings()
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvand committed Feb 19, 2024
1 parent 17168a0 commit 94e69f3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 33 deletions.
15 changes: 4 additions & 11 deletions Yvand.LDAPCPSE/TEMPLATE/ADMIN/LDAPCPSE/GlobalSettings.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ protected void grdLDAPConnections_RowDeleting(object sender, GridViewDeleteEvent
{
Settings.LdapConnections.Remove(tenantToRemove);
CommitChanges();
Logger.Log($"Microsoft Entra ID tenant '{tenantToRemove.LdapPath}' was successfully removed from configuration '{ConfigurationName}'", TraceSeverity.Medium, EventSeverity.Information, TraceCategory.Configuration);
Logger.Log($"Directory '{tenantToRemove.LdapPath}' was successfully removed from configuration '{ConfigurationName}'", TraceSeverity.Medium, EventSeverity.Information, TraceCategory.Configuration);
LabelMessage.Text = String.Format(TextSummaryPersistedObjectInformation, Configuration.Name, Configuration.Version, Configuration.Id);
PopulateConnectionsGrid();
InitializeAugmentation();
Expand Down Expand Up @@ -346,7 +346,7 @@ protected void BtnAddLdapConnection_Click(object sender, EventArgs e)
}

/// <summary>
/// Add new Microsoft Entra ID tenant in persisted object
/// Add new Directory in persisted object
/// </summary>
void AddTenantConnection()
{
Expand All @@ -360,21 +360,14 @@ void AddTenantConnection()

if (this.RbUseServerDomain.Checked)
{
Settings.LdapConnections.Add(
new DirectoryConnection
{
UseDefaultADConnection = true,
EnableAugmentation = true,
}
);
Settings.LdapConnections.Add(new DirectoryConnection(true));
}
else
{
AuthenticationTypes authNType = GetSelectedAuthenticationTypes(true);
Settings.LdapConnections.Add(
new DirectoryConnection
new DirectoryConnection(false)
{
UseDefaultADConnection = false,
LdapPath = this.TxtLdapConnectionString.Text,
Username = this.TxtLdapUsername.Text,
Password = this.TxtLdapPassword.Text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected LdapProviderConfiguration Configuration
}

/// <summary>
/// Gets or sets the settings used by EntraCP to run
/// Gets or sets the settings used by LDAPCP to run
/// </summary>
protected LdapProviderSettings Settings { get; set; }

Expand Down Expand Up @@ -171,7 +171,7 @@ protected string MostImportantError
protected static readonly string ViewStatePersistedObjectVersionKey = "PersistedObjectVersion";
protected static readonly string TextErrorPersistedObjectNotFound = "PersistedObject cannot be found.";
protected static readonly string TextErrorPersistedObjectStale = "Modifications were not applied because the persisted object was modified after this page was loaded. Please refresh the page and try again.";
protected static readonly string TextErrorNoSPTrustAssociation = "{0} is currently not associated with any SPTrustedLoginProvider, which is required to create entities.<br/>Visit <a href=\"" + ClaimsProviderConstants.PUBLICSITEURL + "\" target=\"_blank\">EntraCP site</a> for more information.<br/>Refresh this page once '{0}' is associated with a SPTrustedLoginProvider.";
protected static readonly string TextErrorNoSPTrustAssociation = "{0} is currently not associated with any SPTrustedLoginProvider, which is required to create entities.<br/>Visit <a href=\"" + ClaimsProviderConstants.PUBLICSITEURL + "\" target=\"_blank\">LDAPCP site</a> for more information.<br/>Refresh this page once '{0}' is associated with a SPTrustedLoginProvider.";
protected static readonly string TextErrorNoIdentityClaimType = "The SPTrustedLoginProvider '{0}' is set with identity claim type '{1}', but is not set in claim types configuration list.<br/>Please visit claim types configuration page to add it.";
protected static readonly string TextErrorClaimsProviderNameNotSet = "The attribute 'ClaimsProviderName' must be set in the user control.";
protected static readonly string TextErrorPersistedObjectNameNotSet = "The attribute 'PersistedObjectName' must be set in the user control.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ public DirectoryConnection()
{
}

public DirectoryConnection(bool useDefaultADConnection)
{
this.UseDefaultADConnection = useDefaultADConnection;
if (useDefaultADConnection == true)
{
this.EnableAugmentation = true;
this.GetGroupMembershipUsingDotNetHelpers = true;
}
}

public bool Initialize()
{
if (InitializationSuccessful)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ public static LdapProviderSettings GetDefaultSettings(string claimsProviderName)
LdapProviderSettings entityProviderSettings = new LdapProviderSettings
{
ClaimTypes = LdapProviderSettings.ReturnDefaultClaimTypesConfig(claimsProviderName),
LdapConnections = new List<DirectoryConnection>()
{
new DirectoryConnection(true),
}
};
return entityProviderSettings;
}
Expand Down Expand Up @@ -505,26 +509,6 @@ public virtual ILdapProviderSettings GetDefaultSettings()
return LdapProviderSettings.GetDefaultSettings(this.ClaimsProviderName);
}

/// <summary>
/// Generate and return default configuration
/// </summary>
/// <returns></returns>
public static LdapProviderConfiguration ReturnDefaultConfiguration(string claimsProviderName)
{
LdapProviderConfiguration defaultConfig = new LdapProviderConfiguration();
defaultConfig.ClaimsProviderName = claimsProviderName;
defaultConfig.LdapConnections = new List<DirectoryConnection>
{
new DirectoryConnection
{
UseDefaultADConnection = true,
EnableAugmentation = true,
},
};
defaultConfig.ClaimTypes = LdapProviderSettings.ReturnDefaultClaimTypesConfig(claimsProviderName);
return defaultConfig;
}

public virtual ClaimTypeConfigCollection ReturnDefaultClaimTypesConfig()
{
return LdapProviderSettings.ReturnDefaultClaimTypesConfig(this.ClaimsProviderName);
Expand Down

0 comments on commit 94e69f3

Please sign in to comment.