Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Creates user.
- /// </summary>
- /// <param name="name">User name.</param>
- /// <returns>Newly created user.</returns>
- public IPrincipal CreatePrincipal(string name)
- {
- if (!PrincipalBase.IsValidUserName(name))
- {
- throw new DavException("User name contains invalid characters", DavStatus.FORBIDDEN);
- }
- var userPrincipal = new UserPrincipal(Context.GetPrincipalContext());
- userPrincipal.Name = name;
- userPrincipal.UserPrincipalName = name;
- userPrincipal.Enabled = true;
- userPrincipal.ExpirePasswordNow();
- Context.PrincipalOperation(userPrincipal.Save);
- return new User(userPrincipal, Context);
- }
Add Comment
Please, Sign In to add comment