Implement Add-LDAPIdentitySource
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Collections.Generic;
|
||||
using System.IdentityModel.Selectors;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Security;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.ServiceModel.Security;
|
||||
@@ -16,7 +17,7 @@ using VMware.Binding.WsTrust;
|
||||
using VMware.Binding.WsTrust.SecurityContext;
|
||||
using VMware.vSphere.LsClient;
|
||||
using VMware.vSphere.SsoAdminClient.DataTypes;
|
||||
using VMware.vSphere.SsoAdminClient.SsoAdminServiceReferencer;
|
||||
using VMware.vSphere.SsoAdminClient.SsoAdminServiceReference2;
|
||||
|
||||
namespace VMware.vSphere.SsoAdminClient
|
||||
{
|
||||
@@ -657,6 +658,59 @@ namespace VMware.vSphere.SsoAdminClient
|
||||
})).Wait();
|
||||
}
|
||||
|
||||
public void AddLdapIdentitySource(
|
||||
string domainName,
|
||||
string domainAlias,
|
||||
string friendlyName,
|
||||
string primaryUrl,
|
||||
string baseDNUsers,
|
||||
string baseDNGroups,
|
||||
string authenticationUserName,
|
||||
string authenticationPassword,
|
||||
string serverType,
|
||||
X509Certificate2[] ldapCertificates) {
|
||||
|
||||
string authenticationType = "password";
|
||||
var authorizedInvocationContext =
|
||||
CreateAuthorizedInvocationContext();
|
||||
|
||||
var adminLdapIdentitySourceDetails = new SsoAdminLdapIdentitySourceDetails {
|
||||
friendlyName = friendlyName,
|
||||
primaryUrl = primaryUrl,
|
||||
userBaseDn = baseDNUsers,
|
||||
groupBaseDn = baseDNGroups
|
||||
};
|
||||
|
||||
if (ldapCertificates != null && ldapCertificates.Length > 0) {
|
||||
var certificates = new List<string>();
|
||||
foreach (var ldapCert in ldapCertificates) {
|
||||
if (ldapCert != null) {
|
||||
certificates.Add(ldapCert.ToString());
|
||||
}
|
||||
}
|
||||
if (certificates.Count > 0) {
|
||||
adminLdapIdentitySourceDetails.certificates = certificates.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
authorizedInvocationContext.
|
||||
InvokeOperation(() =>
|
||||
_ssoAdminBindingClient.RegisterLdapAsync(
|
||||
new ManagedObjectReference {
|
||||
type = "SsoAdminDomainManagementService",
|
||||
Value = "domainManagementService"
|
||||
},
|
||||
serverType,
|
||||
domainName,
|
||||
domainAlias,
|
||||
adminLdapIdentitySourceDetails,
|
||||
authenticationType,
|
||||
new SsoAdminIdentitySourceManagementServiceAuthenticationCredentials {
|
||||
username = authenticationUserName,
|
||||
password = authenticationPassword
|
||||
})).Wait();
|
||||
}
|
||||
|
||||
public IEnumerable<IdentitySource> GetDomains() {
|
||||
var authorizedInvocationContext =
|
||||
CreateAuthorizedInvocationContext();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user