Einzelnen Beitrag anzeigen

Benutzerbild von kuba
kuba

Registriert seit: 26. Mai 2006
Ort: Arnsberg
588 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: Objekte im Active Directory verschieben

  Alt 27. Jul 2023, 22:19
Was besseres ist mir jetzt nicht eingefallen, falls noch jemand eine Idee hat bitte melden.

Workaround:

Code:
Memo_defaultVBS:

' This code moves Object from one container to another.
' ------ SCRIPT CONFIGURATION ------
strSource = "#Source" ' e.g. cn=rallen,cn=users,dc=rallencorp,dc=com
strTarget = "#Target" ' e.g. ou=Sales,dc=rallencorp,dc=com
' ------ END CONFIGURATION ---------

Set objSource = GetObject(strSource)
Set objTarget = GetObject(strTarget)
objTarget.MoveHere objSource.ADsPath, objSource.Name


procedure MoveObjectADS:
var
  Source, Target: string;
  Value, filename :string;
  i : integer;
begin
  Memo_VBS.Clear;
  Memo_VBS.Text := Memo_defaultVBS.Text;
  Source:=SearchComputer(lvComputerRoom.Selected.Caption+'$');
  Target:= StringReplace(Source, PCWORKEROUPATH, PCMASTEROUPATH,[rfReplaceAll]);
  Target:= StringReplace(Target, 'CN='+lvComputerRoom.Selected.Caption+',', '',[rfReplaceAll]);
  filename := 'objMove.vbs';
  if FileExists(filename) then DeleteFile(filename);
  for i := 0 to Memo_VBS.Lines.Count - 1 do Memo_VBS.lines[i]:=StringReplace(Memo_VBS.lines[i],'#Source',Source,[rfReplaceAll]);
  for i := 0 to Memo_VBS.Lines.Count - 1 do Memo_VBS.lines[i]:=StringReplace(Memo_VBS.lines[i],'#Target',Target,[rfReplaceAll]);
  Memo_VBS.Lines.SaveToFile(ExtractFilePath(ParamStr(0)) + filename);
  ShellExecAndWait('WScript.exe',PChar(filename),'');
  Application.ProcessMessages;
end;
Stefan Kubatzki
E=mc2
  Mit Zitat antworten Zitat