Example #1
0
        public void ShowAddUser()
        {
            UserDTO userDTO          = new UserDTO();
            AddNewUserController awc = new AddNewUserController(userDTO);
            nint res = NSApplication.SharedApplication.RunModalForWindow(awc.Window);

            if (res == (nint)VMIdentityConstants.DIALOGOK)
            {
                UIErrorHelper.CheckedExec(delegate()
                {
                    LdapMod[] user = new LdapMod[6];
                    user[0]        = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_GIVEN_NAME, new string[] {
                        userDTO.FirstName,
                        null
                    });
                    user[1] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_SN, new string[] {
                        userDTO.LastName,
                        null
                    });
                    user[2] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_CN, new string[] {
                        userDTO.Cn,
                        null
                    });
                    user[3] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_KRB_UPN, new string[] {
                        userDTO.UPN,
                        null
                    });
                    user[4] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_SAM_ACCOUNT_NAME, new string[] {
                        userDTO.SAMAccountName,
                        null
                    });
                    user[5] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_OBJECT_CLASS, new string[] {
                        VMDirConstants.USER_OC,
                        null
                    });
                    string dn = string.Format("cn={0},{1}", userDTO.Cn, Dn);
                    ServerDTO.Connection.AddObject(dn, user);
                    UIErrorHelper.ShowInformation(VMDirConstants.STAT_USR_ADD_SUCC);
                    var oc = Utilities.GetObjectClassList(ServerDTO, dn, LdapScope.SCOPE_BASE);
                    this.Children.Insert(0, new DirectoryNode(dn, oc, ServerDTO, this));
                    //ReloadChildren();
                    RefreshProperties();
                    NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadOutlineView", this);
                    NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadTableView", this);
                });
            }
        }
Example #2
0
        public void ShowAddUser()
        {
            AddNewUserDTO        userDTO = new AddNewUserDTO();
            AddNewUserController awc     = new AddNewUserController(userDTO);
            nint res = NSApplication.SharedApplication.RunModalForWindow(awc.Window);

            if (res == (nint)VMIdentityConstants.DIALOGOK)
            {
                UIErrorHelper.CheckedExec(delegate() {
                    LdapMod[] user = new LdapMod[6];
                    user [0]       = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_GIVEN_NAME, new string[] {
                        userDTO.FirstName,
                        null
                    });
                    user [1] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_SN, new string[] {
                        userDTO.LastName,
                        null
                    });
                    user [2] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_CN, new string[] {
                        userDTO.Cn,
                        null
                    });
                    user [3] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_KRB_UPN, new string[] {
                        userDTO.UPN,
                        null
                    });
                    user [4] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_SAM_ACCOUNT_NAME, new string[] {
                        userDTO.SAMAccountName,
                        null
                    });
                    user [5] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_OBJECT_CLASS, new string[] {
                        "user",
                        null
                    });
                    string dn = string.Format("cn={0},{1}", userDTO.Cn, Name);
                    ServerDTO.Connection.AddObject(dn, user);
                    UIErrorHelper.ShowAlert("", "Successfully added object");
                    ReloadChildren();
                    RefreshProperties();
                    NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadOutlineView", this);
                    NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadTableView", this);
                });
            }
        }