private void CreateNewPortalDomain(DirectoryEntry entry, string parentPath, Guid guid, SyncTree syncTree) { try { AdLog.LogADObject(string.Format("New portal domain - creating under {0}", parentPath), entry.Path); Domain newNode = new Domain(Node.LoadNode(parentPath)); UpdatePortalDomainProperties(entry, newNode, syncTree); Common.UpdateLastSync(newNode, guid); //newNode.Save(); - update lastsync already saves node } catch (Exception ex) { AdLog.LogException(ex); } }
public static User RegisterUser(string fullUserName) { if (string.IsNullOrEmpty(fullUserName)) return null; var slashIndex = fullUserName.IndexOf('\\'); var domain = fullUserName.Substring(0, slashIndex); var username = fullUserName.Substring(slashIndex + 1); var user = User.Load(domain, username); if (user != null) return user; try { AccessProvider.Current.SetCurrentUser(User.Administrator); var dom = Node.Load<Domain>(RepositoryPath.Combine(Repository.ImsFolderPath, domain)); if (dom == null) { //create domain dom = new Domain(Repository.ImsFolder) { Name = domain }; dom.Save(); } //create user user = new User(dom) { Name = username, Enabled = true, FullName = username }; user.Save(); Group.Administrators.AddMember(user); } finally { if (user != null) AccessProvider.Current.SetCurrentUser(user); } return user; }