Answered by:
Adding a computer to the Distribution list on a RunAs Account
Question
-
Using System Center Operations Manager 2007 R2 SDK and C# I am trying to update a RunAs Account.
The account is configured in advance, but I need to add a computer to the accounts distribution list (More secure is selected). I have been checking the MonitoringSecureData class and related classes. But I cannot find any properties or methods that seem to be related to the distribution.
Does anyone know which perperty, method or class to use ?
I am not trying to update RunAs profile here. That part is working already. RunAs Account Distribution.
TIA,
Jan Nielsen
Answers
-
I finally figured out how to do it. Actually it wasn't that difficult once I found out the right method is ApproveCredentialForDistribution.
Sample code without error handling:
public void SetRunasAccount(string strRunAsAccount)
{
MonitoringSecureData account = GetRunasAccount(strRunAsAccount);
List<MonitoringObject> list = new List<MonitoringObject>();
foreach (AgentManagedComputer agent in GetAgents())
{
list.Add(agent.HostedHealthService);
}
m_objMG.ApproveCredentialForDistribution((ISecuredData)account, list);
}- Proposed as answer by Jonathan AlmquistModerator Thursday, October 21, 2010 7:32 PM
- Marked as answer by Jonathan AlmquistModerator Friday, December 31, 2010 5:25 PM
-
Hi All,
Just wanted to let you know I created a Console app for this. Will probably make a blogpost later and share the console app. Some info can be already found here:
Regards,
Stefan
Regards, Stefan Stranger Microsoft Services- Marked as answer by Jonathan AlmquistModerator Saturday, August 6, 2011 4:45 AM
-
Here are a couple examples using powershell.
Using group reference: http://blogs.technet.com/b/jonathanalmquist/archive/2011/08/05/solving-the-problem-of-automated-distributing-of-credentials-group-criteria.aspx
Using literal expression: http://blogs.technet.com/b/jonathanalmquist/archive/2011/08/05/solving-the-problem-of-automated-distribution-of-credentials-literal-expression.aspx
HTH, Jonathan Almquist - MSFT- Marked as answer by Jonathan AlmquistModerator Saturday, August 6, 2011 4:44 AM
All replies
-
Funny!
We're looking for the same thing at about the same time:
I'm hoping to wake up tomorrow morning and have something in PowerShell which you may be able to use as a guide for porting to C#...
-
- Proposed as answer by Marco ShawModerator Friday, September 24, 2010 11:52 AM
- Marked as answer by Nicholas LiModerator Tuesday, September 28, 2010 2:32 AM
- Unmarked as answer by Jan Nielsen Wednesday, October 6, 2010 9:19 AM
- Unproposed as answer by Jan Nielsen Wednesday, October 6, 2010 9:20 AM
-
Hi Marco,
Thanks for replying, but as far as I can see the referenced script updates the runas PROFILE to reference another runas account. I cannot see it changes the runas account distribution list.
I believe Microsofts SDK documentation has such an example already.
Regards,
Jan -
Hi Marco,
Thanks for replying, but as far as I can see the referenced script updates the runas PROFILE to reference another runas account. I cannot see it changes the runas account distribution list.
I believe Microsofts SDK documentation has such an example already.
Regards,
Jan
Agreed. I'll do some more digging, but I can't promise anything at this point. -
I finally figured out how to do it. Actually it wasn't that difficult once I found out the right method is ApproveCredentialForDistribution.
Sample code without error handling:
public void SetRunasAccount(string strRunAsAccount)
{
MonitoringSecureData account = GetRunasAccount(strRunAsAccount);
List<MonitoringObject> list = new List<MonitoringObject>();
foreach (AgentManagedComputer agent in GetAgents())
{
list.Add(agent.HostedHealthService);
}
m_objMG.ApproveCredentialForDistribution((ISecuredData)account, list);
}- Proposed as answer by Jonathan AlmquistModerator Thursday, October 21, 2010 7:32 PM
- Marked as answer by Jonathan AlmquistModerator Friday, December 31, 2010 5:25 PM
-
-
-
Hi. No activity for 30 days. Will mark as answer. Feel free to re-open. Thanks
Anders Bengtsson | Microsoft PFE | blog at http://www.contoso.se- Marked as answer by .Anders BengtssonMicrosoft employee, Moderator Friday, December 31, 2010 9:51 AM
- Unmarked as answer by Jonathan AlmquistModerator Friday, December 31, 2010 5:25 PM
-
Hi All,
Just wanted to let you know I created a Console app for this. Will probably make a blogpost later and share the console app. Some info can be already found here:
Regards,
Stefan
Regards, Stefan Stranger Microsoft Services- Marked as answer by Jonathan AlmquistModerator Saturday, August 6, 2011 4:45 AM
-
Here are a couple examples.
Using group reference: http://blogs.technet.com/b/jonathanalmquist/archive/2011/08/05/solving-the-problem-of-automated-distributing-of-credentials-group-criteria.aspx
Using literal expression: http://blogs.technet.com/b/jonathanalmquist/archive/2011/08/05/solving-the-problem-of-automated-distribution-of-credentials-literal-expression.aspx
HTH, Jonathan Almquist - MSFT -
Here are a couple examples using powershell.
Using group reference: http://blogs.technet.com/b/jonathanalmquist/archive/2011/08/05/solving-the-problem-of-automated-distributing-of-credentials-group-criteria.aspx
Using literal expression: http://blogs.technet.com/b/jonathanalmquist/archive/2011/08/05/solving-the-problem-of-automated-distribution-of-credentials-literal-expression.aspx
HTH, Jonathan Almquist - MSFT- Marked as answer by Jonathan AlmquistModerator Saturday, August 6, 2011 4:44 AM