masastack/MASA.Auth

LdapSaveAsync

huashao1123 opened this issue · 0 comments

var ldapIdp = new LdapIdp(
ldapIdpDto.ServerAddress,
ldapIdpDto.ServerPort,
ldapIdpDto.IsLdaps,
ldapIdpDto.BaseDn,
ldapIdpDto.RootUserDn,
ldapIdpDto.RootUserPassword,
ldapIdpDto.UserSearchBaseDn,
ldapIdpDto.GroupSearchBaseDn);
var dbItem = await _ldapIdpRepository.FindAsync(l => l.Name == ldapIdp.Name);
if (dbItem is null)
{
await _ldapIdpRepository.AddAsync(ldapIdp);
}
else
{
dbItem.Update(ldapIdp);
await _ldapIdpRepository.UpdateAsync(dbItem);
}

await _unitOfWork.SaveChangesAsync();
var ldapUsers = await ldapProvider.GetAllUserAsync().ToListAsync();
await _ldapDomainService.SyncLdapUserAsync(ldapUsers);
----------需要增加await _unitOfWork.SaveChangesAsync();保存结果,否则后面查找会有问题