Hi,
For a console extension, I need to connect to the site server. Since the extension is running inside the console (i.e. it is already connected to a site server), how do I get the siteserver name so that I do not need to instantiate the WqlConnectionManager and have to feed it the sitename, userid and password. My point here is that the extension would not be loaded if a valid connection to the site server did not exist. So the classic connection example code always makes you create a WqlConnectionManager and have to pass credentials. This would be really inconvenient to the end-user and make the console extension frustrating to use. I thought that the SmsNamedValuesDictionary would contain all the "##SUB" properties like ADSiteName (which is what I need to feed into the WqlConnectionManager contructor) but it is empty.
Below is the code I am using (which is what all the examples are using). So to beat a dead horse, the console exentsion assembly would not be properly loaded if a valid connection to a site server did not exist so how can I reuse (in my code) the valid connection? Hope this makes sense. Thanks in advance.
private bool ConnectToSCCM(string stringServerName_in, string stringUserName_in, string stringPassword_in) { bool l_boolConnectedToSCCM = false; try { //##SUB:ADSiteName## SmsNamedValuesDictionary namedValues = new SmsNamedValuesDictionary(); m_WqlConnectionManager = new WqlConnectionManager(namedValues); if (System.Net.Dns.GetHostName().ToUpper() == stringServerName_in.ToUpper()) { m_WqlConnectionManager.Connect(stringServerName_in); } else { m_WqlConnectionManager.Connect(stringServerName_in, stringUserName_in, stringPassword_in); } l_boolConnectedToSCCM = true; } catch (SmsException ex) { MessageBox.Show("Failed to connect to SCCM. Error: " + ex.Message); } catch (UnauthorizedAccessException ex) { MessageBox.Show("Failed to authenticate to SCCM. Error:" + ex.Message); } return (l_boolConnectedToSCCM); }