I have a loop that looks at multiple GW users and performs various functions against the user. Everything works the first pass through the loop no mater what operation is executed. Any successive passes through the loop causes an access violation error. It seems that if I have multiple actions of the same type in succession they work fine. Its only when there are a mix of actions that I get the error.

Thanks,

Example

vSystem:=CreateOleObject('NovellGroupWareAdmin');
vSystem.Connect(GWDomainPath);

for each user do
begin
case action of
1. begin // Modify DN
vDomain:= vSystem.ConnectedDomain;
vUser:= vDomain.Users.ItemByDN(UserDN);
vUser.MoveWithinTree(NewContainerDN);
end;
2: begin // Clear Exp Date
vDomain:= vSystem.ConnectedDomain;
vUser:= vDomain.Users.ItemByDN(UserDn);
vUser.MailboxExpDate:= VarFromDateTime(0);
vUser.commit;
end;
3: begin // Change User Name
vDomain:=vSystem.ConnectedDomain;
GWDomain:= vDomain.Name;

GWPO:= '';
vPostOffices:=vDomain.PostOffices;
vPOIterator:=vPostOffices.CreateIterator;
vPostOffice:=vPOIterator.Next;
While ((NOT VarIsNULL(vPostOffice)) and (NOT varisempty(vPostOffice)) and (GWPO = '')) do
begin
if not vPostOffice.IsUserNameUnique(LDAP_UCode) then
GWPO:= vPostOffice.Name;
vPostOffice:=vPOIterator.Next;
end;

vDomain:=vSystem.ConnectedDomain;
vUser:= vDomain.Users.ItemByDN(LDAPtoNDS_DN(LDAP_DN));
GWMailBox:= vUser.MailboxID;
vUser:= vSystem.vUsers.AddExistingUser(NewUcode, NewDN, '', GWPO, GWDomain, GWMailBox);
end;
end;
end;