public UserOUs(OrganizationalUnitAPIs organizationalUnitAPIs, bool addOU) { InitializeComponent(); try { this.organizationalUnitRepository = CommonNinject.Kernel.Get <IOrganizationalUnitRepository>(); LocationAPIs locationAPIs = new LocationAPIs(CommonNinject.Kernel.Get <ILocationAPIRepository>()); this.combexNewLocationID.DataSource = locationAPIs.GetLocationBases(); this.combexNewLocationID.DisplayMember = CommonExpressions.PropertyName <LocationBase>(p => p.Name); this.combexNewLocationID.ValueMember = CommonExpressions.PropertyName <LocationBase>(p => p.LocationID); this.bindingNewLocationID = this.combexNewLocationID.DataBindings.Add("SelectedValue", this, "NewLocationID", true, DataSourceUpdateMode.OnPropertyChanged); this.bindingNewLocationID.BindingComplete += binding_BindingComplete; this.organizationalUnitAPIs = organizationalUnitAPIs; this.combexOrganizationalUnitID.DataSource = this.organizationalUnitAPIs.GetOrganizationalUnitIndexes(); this.combexOrganizationalUnitID.DisplayMember = CommonExpressions.PropertyName <OrganizationalUnitIndex>(p => p.LocationOrganizationalUnitName); this.combexOrganizationalUnitID.ValueMember = CommonExpressions.PropertyName <OrganizationalUnitIndex>(p => p.OrganizationalUnitID); this.bindingOrganizationalUnitID = this.combexOrganizationalUnitID.DataBindings.Add("SelectedValue", this, CommonExpressions.PropertyName <OrganizationalUnitIndex>(p => p.OrganizationalUnitID), true, DataSourceUpdateMode.OnPropertyChanged); this.bindingOrganizationalUnitID.BindingComplete += binding_BindingComplete; this.textexNewOrganizationalUnitID.TextChanged += textexNewOrganizationalUnitID_TextChanged; this.addOU = addOU; this.labelOrganizationalUnitID.Visible = !this.addOU; this.combexOrganizationalUnitID.Visible = !this.addOU; this.labelNewOrganizationalUnitID.Visible = this.addOU; this.textexNewOrganizationalUnitID.Visible = this.addOU; this.labelNewLocationID.Visible = this.addOU; this.combexNewLocationID.Visible = this.addOU; this.Text = this.addOU ? "Add new organizational unit" : "Remove OU"; this.buttonOK.Text = this.addOU ? "Add" : "Remove"; } catch (Exception exception) { ExceptionHandlers.ShowExceptionMessageBox(this, exception); } }
public UserReferences() { InitializeComponent(); try { this.SelectedUserID = ContextAttributes.User.UserID; ModuleAPIs moduleAPIs = new ModuleAPIs(CommonNinject.Kernel.Get <IModuleAPIRepository>()); this.fastNMVNTasks.ShowGroups = true; this.fastNMVNTasks.AboutToCreateGroups += fastNMVNTasks_AboutToCreateGroups; this.fastNMVNTasks.SetObjects(moduleAPIs.GetModuleDetailIndexes()); this.fastNMVNTasks.Sort(this.olvModuleName, SortOrder.Ascending); this.userRepository = CommonNinject.Kernel.Get <IUserRepository>(); this.userAPIs = new UserAPIs(CommonNinject.Kernel.Get <IUserAPIRepository>()); this.organizationalUnitAPIs = new OrganizationalUnitAPIs(CommonNinject.Kernel.Get <IOrganizationalUnitAPIRepository>()); this.treeUserID.RootKeyValue = 0; this.treeUserID.SelectedIndexChanged += treeUserID_SelectedIndexChanged; this.comboActiveOption.SelectedIndex = 0; this.comboUserID.ComboBox.DisplayMember = CommonExpressions.PropertyName <UserIndex>(p => p.UserName); this.comboUserID.ComboBox.ValueMember = CommonExpressions.PropertyName <UserIndex>(p => p.UserID); this.bindingUserID = this.comboUserID.ComboBox.DataBindings.Add("SelectedValue", this, "SelectedUserID", true, DataSourceUpdateMode.OnPropertyChanged); this.gridexUserAccessControl.AutoGenerateColumns = false; this.gridexUserAccessControl.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; this.bindingListUserAccessControls = new BindingList <UserAccessControlDTO>(); this.gridexUserAccessControl.DataSource = this.bindingListUserAccessControls; this.bindingListUserAccessControls.ListChanged += bindingListUserAccessControls_ListChanged; StackedHeaderDecorator stackedHeaderDecorator = new StackedHeaderDecorator(this.gridexUserAccessControl); } catch (Exception exception) { ExceptionHandlers.ShowExceptionMessageBox(this, exception); } }
public UserRegister(UserAPIs userAPIs, OrganizationalUnitAPIs organizationalUnitAPIs) { InitializeComponent(); try { List <DomainUser> allUsers = new List <DomainUser>(); //userAPIs.UpdateUserName("S-1-5-21-3775195119-1044016383-3360809325-1001", "NMVN\vendor"); if (true) { PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "chevronvn.com"); //, "OU=SomeOU,dc=YourCompany,dc=com"// create your domain context and define the OU container to search in UserPrincipal qbeUser = new UserPrincipal(ctx); // define a "query-by-example" principal - here, we search for a UserPrincipal (user) PrincipalSearcher srch = new PrincipalSearcher(qbeUser); // create your principal searcher passing in the QBE principal foreach (var found in srch.FindAll()) // find all matches { // do whatever here - "found" is of type "Principal" - it could be user, group, computer..... if (found.Sid.Value != null && found.Sid.Value != "" && found.SamAccountName != null && found.SamAccountName != "") { userAPIs.UpdateUserName(found.Sid.Value, found.SamAccountName); } allUsers.Add(new DomainUser() { FirstName = "", LastName = "", UserName = found.SamAccountName, SecurityIdentifier = found.Sid.Value }); //found.UserPrincipalName: the same as SamAccountName, but with @chevron.com } } else { for (int i = 1; i <= 5; i++) { allUsers.Add(new DomainUser() { FirstName = "FIST NAME" + i.ToString(), LastName = "FIST NAME" + i.ToString(), UserName = "******", SecurityIdentifier = "S-1-5-21-2907738014-1953812902-1740135539-2131" }); } } this.combexUserID.DataSource = allUsers; this.combexUserID.DisplayMember = CommonExpressions.PropertyName <DomainUser>(p => p.UserName); this.combexUserID.ValueMember = CommonExpressions.PropertyName <DomainUser>(p => p.UserName); this.bindingUserName = this.combexUserID.DataBindings.Add("SelectedValue", this, CommonExpressions.PropertyName <DomainUser>(p => p.UserName), true, DataSourceUpdateMode.OnPropertyChanged); this.bindingUserName.BindingComplete += binding_BindingComplete; this.userAPIs = userAPIs; this.organizationalUnitAPIs = organizationalUnitAPIs; this.combexOrganizationalUnitID.DataSource = this.organizationalUnitAPIs.GetOrganizationalUnitIndexes(); this.combexOrganizationalUnitID.DisplayMember = CommonExpressions.PropertyName <OrganizationalUnitIndex>(p => p.LocationOrganizationalUnitName); this.combexOrganizationalUnitID.ValueMember = CommonExpressions.PropertyName <OrganizationalUnitIndex>(p => p.OrganizationalUnitID); this.bindingOrganizationalUnitID = this.combexOrganizationalUnitID.DataBindings.Add("SelectedValue", this, CommonExpressions.PropertyName <OrganizationalUnitIndex>(p => p.OrganizationalUnitID), true, DataSourceUpdateMode.OnPropertyChanged); this.bindingOrganizationalUnitID.BindingComplete += binding_BindingComplete; this.SameOUAccessLevel = GlobalEnums.AccessLevel.NoAccess; this.combexSameOUAccessLevels.DataSource = new List <ACL>() { new ACL() { AccessLevelID = GlobalEnums.AccessLevel.NoAccess }, new ACL() { AccessLevelID = GlobalEnums.AccessLevel.Readable }, new ACL() { AccessLevelID = GlobalEnums.AccessLevel.Editable } }; this.combexSameOUAccessLevels.DisplayMember = CommonExpressions.PropertyName <ACL>(p => p.AccessLevelName); this.combexSameOUAccessLevels.ValueMember = CommonExpressions.PropertyName <ACL>(p => p.AccessLevelID); this.combexSameOUAccessLevels.DataBindings.Add("SelectedValue", this, "SameOUAccessLevel", true, DataSourceUpdateMode.OnPropertyChanged); this.SameLocationAccessLevel = GlobalEnums.AccessLevel.NoAccess; this.combexSameLocationAccessLevels.DataSource = new List <ACL>() { new ACL() { AccessLevelID = GlobalEnums.AccessLevel.NoAccess }, new ACL() { AccessLevelID = GlobalEnums.AccessLevel.Readable }, new ACL() { AccessLevelID = GlobalEnums.AccessLevel.Editable } }; this.combexSameLocationAccessLevels.DisplayMember = CommonExpressions.PropertyName <ACL>(p => p.AccessLevelName); this.combexSameLocationAccessLevels.ValueMember = CommonExpressions.PropertyName <ACL>(p => p.AccessLevelID); this.combexSameLocationAccessLevels.DataBindings.Add("SelectedValue", this, "SameLocationAccessLevel", true, DataSourceUpdateMode.OnPropertyChanged); this.OtherOUAccessLevel = GlobalEnums.AccessLevel.NoAccess; this.combexOtherOUAccessLevels.DataSource = new List <ACL>() { new ACL() { AccessLevelID = GlobalEnums.AccessLevel.NoAccess }, new ACL() { AccessLevelID = GlobalEnums.AccessLevel.Readable } }; this.combexOtherOUAccessLevels.DisplayMember = CommonExpressions.PropertyName <ACL>(p => p.AccessLevelName); this.combexOtherOUAccessLevels.ValueMember = CommonExpressions.PropertyName <ACL>(p => p.AccessLevelID); this.combexOtherOUAccessLevels.DataBindings.Add("SelectedValue", this, "OtherOUAccessLevel", true, DataSourceUpdateMode.OnPropertyChanged); } catch (Exception exception) { ExceptionHandlers.ShowExceptionMessageBox(this, exception); } }