-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #660 from Blazam-App/v1-Nightly
v1.2 update
- Loading branch information
Showing
139 changed files
with
14,736 additions
and
614 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using BLAZAM.ActiveDirectory.Interfaces; | ||
using BLAZAM.Common.Data; | ||
using BLAZAM.Database.Models.Templates; | ||
using BLAZAM.EmailMessage.Email.Notifications; | ||
using MudBlazor; | ||
using System.Security; | ||
|
||
namespace BLAZAM.Helpers | ||
{ | ||
public static class Helpers | ||
{ | ||
public static IADUser GenerateTemplateUser(this DirectoryTemplate template, NewUserName newUserName, IActiveDirectoryContext directory) | ||
{ | ||
IADUser? newUser; | ||
var ou = directory.OUs.FindOuByString(template.EffectiveParentOU).FirstOrDefault(); | ||
if (ou == null) throw new ApplicationException("OU could not be found for new user"); | ||
var displayName = template.GenerateDisplayName(newUserName); | ||
newUser = ou.CreateUser(displayName); | ||
|
||
newUser.SamAccountName = template.GenerateUsername(newUserName); | ||
newUser.DisplayName = displayName; | ||
//newUser.SetPassword(template.GeneratePassword().ToSecureString(),false); | ||
//newUser.CanonicalName = template.GenerateDisplayName(newUserName); | ||
newUser.StagePasswordChange(template.GeneratePassword(newUserName).ToSecureString()); | ||
if (template.EffectiveRequirePasswordChange == true) | ||
newUser.StageRequirePasswordChange(true); | ||
if (!newUserName.GivenName.IsNullOrEmpty()) | ||
newUser.GivenName = newUserName.GivenName; | ||
if (!newUserName.MiddleName.IsNullOrEmpty()) | ||
newUser.MiddleName = newUserName.MiddleName; | ||
if (!newUserName.Surname.IsNullOrEmpty()) | ||
newUser.Surname = newUserName.Surname; | ||
|
||
|
||
|
||
template.EffectiveAssignedGroupSids.ForEach(sid => | ||
{ | ||
var group = directory.Groups.FindGroupBySID(sid.GroupSid); | ||
if (group != null) | ||
newUser.AssignTo(group); | ||
|
||
}); | ||
return newUser; | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.