Implement Get-IdnetitySource advanced function

This commit is contained in:
dmilov
2020-11-26 17:41:10 +02:00
parent dc5a755805
commit c212b24cbb
13 changed files with 304 additions and 7 deletions

View File

@@ -0,0 +1,26 @@
// **************************************************************************
// Copyright 2020 VMware, Inc.
// **************************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VMware.vSphere.SsoAdminClient.DataTypes
{
public class ActiveDirectoryIdentitySource : IdentitySource
{
public string Type { get; set; }
public string Alias { get; set; }
public string AuthenticationType { get; set; }
public string AuthenticationUsername { get; set; }
public string FriendlyName { get; set; }
public string PrimaryUrl { get; set; }
public string UserBaseDN { get; set; }
public string GroupBaseDN { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
// **************************************************************************
// Copyright 2020 VMware, Inc.
// **************************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VMware.vSphere.SsoAdminClient.DataTypes
{
public class IdentitySource
{
public string Name { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
// **************************************************************************
// Copyright 2020 VMware, Inc.
// **************************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VMware.vSphere.SsoAdminClient.DataTypes
{
public class LocalOSIdentitySource : IdentitySource
{
}
}

View File

@@ -0,0 +1,16 @@
// **************************************************************************
// Copyright 2020 VMware, Inc.
// **************************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VMware.vSphere.SsoAdminClient.DataTypes
{
public class SystemIdentitySource : IdentitySource
{
}
}

View File

@@ -656,6 +656,45 @@ namespace VMware.vSphere.SsoAdminClient
password = authenticationPassword
})).Wait();
}
public IEnumerable<IdentitySource> GetDomains() {
var authorizedInvocationContext =
CreateAuthorizedInvocationContext();
var domains = authorizedInvocationContext.
InvokeOperation(() =>
_ssoAdminBindingClient.GetDomainsAsync(
new ManagedObjectReference {
type = "SsoAdminDomainManagementService",
Value = "domainManagementService"
})).Result;
if (domains != null) {
var localos = new LocalOSIdentitySource();
localos.Name = domains.localOSDomainName;
yield return localos;
var system = new SystemIdentitySource();
system.Name = domains.systemDomainName;
yield return system;
if (domains.externalDomains != null && domains.externalDomains.Length > 0) {
foreach (var externalDomain in domains.externalDomains) {
var extIdentitySource = new ActiveDirectoryIdentitySource();
extIdentitySource.Name = externalDomain.name;
extIdentitySource.Alias = externalDomain.alias;
extIdentitySource.Type = externalDomain.type;
extIdentitySource.AuthenticationType = externalDomain.authenticationDetails?.authenticationType;
extIdentitySource.AuthenticationUsername = externalDomain.authenticationDetails?.username;
extIdentitySource.FriendlyName = externalDomain.details?.friendlyName;
extIdentitySource.PrimaryUrl = externalDomain.details?.primaryUrl;
extIdentitySource.GroupBaseDN = externalDomain.details?.groupBaseDn;
extIdentitySource.UserBaseDN = externalDomain.details?.userBaseDn;
yield return extIdentitySource;
}
}
}
}
#endregion
}
}