Deprovision multiple connectors in multiple MA's
I'm trying to deprovision all connectors in mutiple MA's with similar names. First thought was to try this. private void DeprovisionAS400(MVEntry mventry) { ConnectedMACollection cMAc = mventry.ConnectedMAs; foreach (ConnectedMA cMA in cMAc) { if (cMA.Name.StartsWith("AS400__" ) && mventry["EmployeeStatus"].Value.ToUpperInvariant() == "TERMINATED" ) cMA.Connectors.DeprovisionAll(); } } The issue is that you can't modify objects inside of a foreach loop or you get System.InvalidOperationException: Collection was modified; enumeration operation may not execute. Any other ideas how to accomlish this? Frank C. Drewes III - Consultant: Certified Security Solutions - My blog: http://www.css-security.com/author/fdrewes
September 10th, 2011 5:31pm

When you say "similar names" ... similar names to what Frank? Regardless, I think your problem is the cMA.Connectors.DeprovisionAll() statement. I am pretty sure you can only call DeprovisionAll() on a single MVEntry ... so you probably want to loop through the Connectors collection. Something like: ConnectedMACollectioncMAc = mventry.ConnectedMAs; foreach (ConnectedMA cMA incMAc) { if (cMA.Name.StartsWith("AS400__") { foreach(MVEntry mve in cMA.Connectors) { if (mve["EmployeeStatus"].Value.ToUpperInvariant() == "TERMINATED") { mve.DeprovisionAll(); } } } } I'm going on memory here, and I've not tried what you're trying, but I'm presuming that cMA.Connectors is the complete set of connectors for a given MA ... however it may not be. Give it a try.Bob Bradley (FIMBob @ http://thefimteam.com/) ... now using Event Broker 3.0 @ http://www.fimeventbroker.com/ for just-in-time delivery of FIM 2010 policy via the sync engine
Free Windows Admin Tool Kit Click here and download it now
September 11th, 2011 7:16am

Bob, Thanks for the ideas. What I have are several MAs that have the same name prefix (i.e. AS400__Server1, AS400__Server2)... I want to deprovision all the connectors in them. So I'm stepping through all the connected MAs, seeing if they are the ones I want to deprovision, and calling the DeprovisionAll method. After investigating further, the issue is generic to modifying some types while iterating through a collection of them. Interestingly, this is a runtime error and not a compile error. I found a few different ways to get around this. Once I determine the cleanest I'll post back the results here.Frank C. Drewes III - Consultant: Certified Security Solutions - My blog: http://www.css-security.com/author/fdrewes
September 11th, 2011 3:11pm

I have one SQL MA that ends up with multiple connectors, and in determining which are ready to deprovision and then removing the particular connector I had a similar problem. The answer I found was not to call the deprovision method while cycling through, but to make note of them for later. Perhaps something similar would work for you. Dim OutdatedCSE(SQLMA.Connectors.Count) As ReferenceValue Dim numRemovals As Integer = 0 For Each CSE As CSEntry In SQLMA.Connectors If [put your logic here to determine if it should disconnect] Then OutdatedCSE(numRemovals) = CSE.DN numRemovals += 1 End If Next For i As Integer = 0 To numRemovals - 1 SQLMA.Connectors.ByDN(OutdatedCSE(i)).Deprovision() Next
Free Windows Admin Tool Kit Click here and download it now
September 12th, 2011 2:06pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics