Video Screencast Help
Protect Your POS Environment Against Retail Data Breaches. Learn More.
Endpoint Management Community Blog

Executing ASDK Methods Using Multiple DS Servers

Created: 02 Apr 2007 • Updated: 20 Jul 2007
Screenbert's picture
0 0 Votes
Login to vote

If you ever need to execute a method against different DS servers when using the Web service in the ASDK use this code to switch between servers. This is useful when you need to find out which DS server a computer is located on and then execute a method against that computer.

ComputerManagementService computerManagement = new ComputerManagementService();
String strTargetServer = "SERVER.DOMAIN.COM";
computerManagement.Url = string.Format( "http://{0}/Altiris/ASDK.NS/ItemManagementService.asmx", strTargetServer);
CredentialCache cache = new CredentialCache();
cache.Add( new Uri(itemMS.Url), "Negotiate", new NetworkCredential( username, password, domain ) );
computerManagement.Credentials = cache;

Just change the strTargetServer to the next server. You could wrap this code in your own method to loop through all your servers and return the proper server that has the computer you are looking for.