Skip to content

Commit

Permalink
Confirm rename entry
Browse files Browse the repository at this point in the history
  • Loading branch information
ibv committed Mar 5, 2017
1 parent 422e4ad commit 4ea5883
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Constant.pas
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ interface
rPostfixMailAddress = 'Postfix\MailAddress';
rPostfixMaildrop = 'Postfix\Maildrop';
rQuickSearchFilter = 'QuickSearchFilter';
rRenamePrompt = 'RenamePrompt';
rAdDisplayName = 'Ad\DisplayName';
rAdCommonName = 'Ad\CommonName';
rAdHomeDrive = 'Ad\HomeDrive';
Expand Down Expand Up @@ -517,6 +518,7 @@ interface
stPassDiff = 'Passwords do not match!';
stPassFor = 'Password for : %s';
stRepeatCopyAction= 'Repeat for all';
stRenameEntry = 'Rename entry to %s?';
stMutuallyExclusive = 'The options "%s" and "%s" can not be selected simultaneously!';
stPwdInclude = 'Include passwords';
stPwdNotEncrypted = 'Warning: exported passwords will not be encrypted!';
Expand Down
23 changes: 23 additions & 0 deletions Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,26 @@ procedure TMainFrm.LDAPTreeEdited(Sender: TObject; Node: TTreeNode; var S: Strin
var
newdn, pdn, temp: string;
i: Integer;

function ConfirmRename: Boolean;
var
cbx: Boolean;
begin
Result := true;
cbx := not GlobalConfig.ReadBool(rRenamePrompt, true);
if cbx then
exit;
temp := Node.Text;
Node.Text := S;
if CheckedMessageDlg(Format(stRenameEntry, [S]), mtConfirmation, [mbYes, mbNo], stDoNotShowAgain, cbx) <> mrYes then
begin
S := temp;
Result := false;
end;
if cbx then
GlobalConfig.WriteBool(rRenamePrompt, false);
end;

begin
i := Pos('=', S);
if i = 0 then
Expand All @@ -1508,6 +1528,9 @@ procedure TMainFrm.LDAPTreeEdited(Sender: TObject; Node: TTreeNode; var S: Strin
newdn := Copy(S, 1, i - 1) + '=' + EncodeLdapString(Copy(S, i + 1, Length(S) - i));
pdn := GetDirFromDn(TObjectInfo(LDAPTree.Selected.Data).dn);

if not ConfirmRename then
exit;

if not (FConnection is TDBConnection) and (FConnection.Version >= LDAP_VERSION3) then
FConnection.RenameEntry(TObjectInfo(LDAPTree.Selected.Data).dn, newdn, pdn)
else
Expand Down

0 comments on commit 4ea5883

Please sign in to comment.