mirror of
https://github.com/freedbygrace/ActiveDirectoryToRestApi.git
synced 2026-07-26 11:28:20 +00:00
Add lockoutTime
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
<UserSecretsId>d52504e9-ea6e-4152-a52e-467ca002e47c</UserSecretsId>
|
<UserSecretsId>d52504e9-ea6e-4152-a52e-467ca002e47c</UserSecretsId>
|
||||||
<AssemblyVersion>$(PackageVersion)</AssemblyVersion>
|
<AssemblyVersion>$(PackageVersion)</AssemblyVersion>
|
||||||
<FileVersion>$(PackageVersion)</FileVersion>
|
<FileVersion>$(PackageVersion)</FileVersion>
|
||||||
<Version>1.0.0.4</Version>
|
<Version>1.0.0.5</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class UserController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("/email")]
|
[HttpPost("/email")]
|
||||||
public ActionResult<User> Email(string email = "test.user@zimbres.com")
|
public ActionResult<User> Email(string email = "test.user@zimbres.loc")
|
||||||
{
|
{
|
||||||
var user = _ldapService.GetUserByEmail(email);
|
var user = _ldapService.GetUserByEmail(email);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ public class User
|
|||||||
public string PasswordExpiration { get; set; }
|
public string PasswordExpiration { get; set; }
|
||||||
public bool Expired { get; set; }
|
public bool Expired { get; set; }
|
||||||
public string Expiration { get; set; }
|
public string Expiration { get; set; }
|
||||||
|
public bool IsLocked { get; set; }
|
||||||
|
public string LockoutTime { get; set; }
|
||||||
public string DistinguishedName { get; set; }
|
public string DistinguishedName { get; set; }
|
||||||
public List<string> Groups { get; set; }
|
public List<string> Groups { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class LdapService
|
|||||||
private User GetUser(string filter)
|
private User GetUser(string filter)
|
||||||
{
|
{
|
||||||
string[] attributesToReturn = { "givenName", "sn", "mail", "userPrincipalName", "displayName", "sAMAccountName",
|
string[] attributesToReturn = { "givenName", "sn", "mail", "userPrincipalName", "displayName", "sAMAccountName",
|
||||||
"userAccountControl", "accountExpires", "memberOf", "distinguishedName", "pwdLastSet" };
|
"userAccountControl", "accountExpires", "memberOf", "distinguishedName", "pwdLastSet", "lockoutTime" };
|
||||||
|
|
||||||
SearchRequest searchRequest = new(_ldapConfigs.DistinguishedName, filter, SearchScope.Subtree, attributesToReturn);
|
SearchRequest searchRequest = new(_ldapConfigs.DistinguishedName, filter, SearchScope.Subtree, attributesToReturn);
|
||||||
|
|
||||||
@@ -40,6 +40,15 @@ public class LdapService
|
|||||||
{
|
{
|
||||||
SearchResultEntry entry = searchResponse.Entries[0];
|
SearchResultEntry entry = searchResponse.Entries[0];
|
||||||
|
|
||||||
|
bool isLocked = false;
|
||||||
|
string lockoutTime = string.Empty;
|
||||||
|
if (entry.Attributes.Contains("lockoutTime"))
|
||||||
|
{
|
||||||
|
var lockoutTimeTicks = entry.Attributes["lockoutTime"][0].ToString();
|
||||||
|
isLocked = lockoutTimeTicks != "0";
|
||||||
|
lockoutTime = lockoutTimeTicks.ConvertToDateTime();
|
||||||
|
}
|
||||||
|
|
||||||
string userAccountControl = entry.Attributes["userAccountControl"][0].ToString();
|
string userAccountControl = entry.Attributes["userAccountControl"][0].ToString();
|
||||||
string accountExpires = entry.Attributes["accountExpires"][0].ToString();
|
string accountExpires = entry.Attributes["accountExpires"][0].ToString();
|
||||||
string expiration = accountExpires.ConvertToDateTime();
|
string expiration = accountExpires.ConvertToDateTime();
|
||||||
@@ -82,6 +91,8 @@ public class LdapService
|
|||||||
PasswordExpiration = passwordExpiration,
|
PasswordExpiration = passwordExpiration,
|
||||||
Expiration = expiration,
|
Expiration = expiration,
|
||||||
Expired = expired,
|
Expired = expired,
|
||||||
|
IsLocked = isLocked,
|
||||||
|
LockoutTime = lockoutTime,
|
||||||
DistinguishedName = distinguishedName,
|
DistinguishedName = distinguishedName,
|
||||||
Groups = groups
|
Groups = groups
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -30,10 +30,10 @@
|
|||||||
"Server": "192.168.100.25",
|
"Server": "192.168.100.25",
|
||||||
"Port": 636,
|
"Port": 636,
|
||||||
"UseSSL": true,
|
"UseSSL": true,
|
||||||
"DomainName": "AD", // (pre-Windows 2000)
|
"DomainName": "ZIMBRES", // (pre-Windows 2000)
|
||||||
"User": "ldapAdmin",
|
"User": "ldapAdmin",
|
||||||
"Pass": "Thi$1sMyPassw0rd",
|
"Pass": "Thi$1sMyPassw0rd",
|
||||||
"DistinguishedName": "DC=ad,DC=zimbres,DC=com"
|
"DistinguishedName": "DC=zimbres,DC=loc"
|
||||||
},
|
},
|
||||||
"Configuration": {
|
"Configuration": {
|
||||||
"Authorization": "Bearer v63M9FlOhqAohJ7oGmFrhVIj",
|
"Authorization": "Bearer v63M9FlOhqAohJ7oGmFrhVIj",
|
||||||
|
|||||||
Reference in New Issue
Block a user