Implement Get/Set-PasswordPolicy cmdlets

This commit is contained in:
dmilov
2020-09-30 12:17:36 +03:00
parent b8030e4272
commit c53453abb2
10 changed files with 505 additions and 82 deletions

View File

@@ -0,0 +1,36 @@
// **************************************************************************
// Copyright (c) VMware, Inc. All rights reserved. -- VMware Confidential.
// **************************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VMware.vSphere.SsoAdminClient.DataTypes
{
public class PasswordPolicy
{
SsoAdminClient _client;
public PasswordPolicy(SsoAdminClient client) {
_client = client;
}
public string Description { get; set; }
public int ProhibitedPreviousPasswordsCount { get; set; }
public int MinLength { get; set; }
public int MaxLength { get; set; }
public int MinNumericCount { get; set; }
public int MinSpecialCharCount { get; set; }
public int MaxIdenticalAdjacentCharacters { get; set; }
public int MinAlphabeticCount { get; set; }
public int MinUppercaseCount { get; set; }
public int MinLowercaseCount { get; set; }
public int PasswordLifetimeDays { get; set; }
public SsoAdminClient GetClient() {
return _client;
}
}
}

View File

@@ -11,6 +11,11 @@ namespace VMware.vSphere.SsoAdminClient.DataTypes
{
public class PersonUser
{
SsoAdminClient _client;
public PersonUser(SsoAdminClient client) {
_client = client;
}
public string Name { get; set; }
public string Domain { get; set; }
public string Description { get; set; }
@@ -18,6 +23,10 @@ namespace VMware.vSphere.SsoAdminClient.DataTypes
public string LastName { get; set; }
public string EmailAddress { get; set; }
public SsoAdminClient GetClient() {
return _client;
}
public override string ToString() {
return $"{Name}@{Domain}";
}

View File

@@ -42,7 +42,7 @@ namespace VMware.vSphere.SsoAdminClient
private void RenewIfNeeded() {
if (_validToken == null ||
_validToken.Expires < (DateTime.Now - new TimeSpan(0, 0, 30))) {
_validToken.Expires < (DateTime.Now + new TimeSpan(0, 0, 30))) {
_validToken = _stsClient.IssueBearerTokenByUserCredential(
_user,
_password);