This is a routine to pass in a username, password, domain, domainname, datarow to connect using .NET and WMI.. Even though this is just a snippet, this route would help connect to any domain it has to be in the format domainuser.This is a routine to pass in a username, password, domain, domainname, datarow to connect using .NET and WMI.. Even though this is just a snippet, this route would help connect to any domain it has to be in the format domain\user. This returns the computer system collection via WMI. Hope this helps. Sub ComputerInfo (ByVal strCN As String, ByVal strDomainName As String, ByVal shtDomainid As Short, ByVal strUID As String, ByVal strPWD As String, ByRef theRow As DataRow)
Dim options As New ConnectionOptions()
options.Username = strUID
options.Password = strPWD
Dim scope As New ManagementScope("\Computer.Domain.comrootcimv2", options)
'***************************************************************************
'Retrieves ComputerSystem, OperatingSystem query strings from app.config ' This is an SQL Formatted WMI query.
'***************************************************************************
Dim strCSquery As String = "Select * from Win32_ComputerSystem" Dim objCSQuery As New WqlObjectQuery(strCSquery) Dim objCSsearcher As New ManagementObjectSearcher(scope, objCSQuery)
Dim envVar As ManagementObject
Dim rowComputer As DataRow
Dim objCSItem As PropertyData Dim strCSColName As String
Try
scope.Connect()
Catch f As Exception
Console.WriteLine(f.Message)
Exit Sub
End Try
Try
For Each envVar In objCSsearcher.Get()
Try
For Each objCSItem In envVar.Properties
strCSColName = objCSItem.Name
If Convert.ToString(objCSItem.Value) <> String.Empty Then
theRow.Item(strCSColName) = objCSItem.Value
Else
theRow.Item(strCSColName) = Convert.DBNull
End If
Next
Catch f As Exception
Console.WriteLine(f.Message) End Try
Next
Catch f As Exception
Console.WriteLine(f.Message) End Try
End Sub
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP.NET Articles More By Steve Schofield developerWorks - FREE Tools! | Attend this launch webcast with Scott Hebner, Vice President of IBM Rational Marketing and Strategy, for an overview of Rational’s new software offerings and resources to help modernize and accelerate software innovation on i on Power Systems – while ensuring past application investments are protected and continue to grow. Learn how these solutions are helping customers extend their core i5/OS solutions toward modern architectures such as SOA and web technologies to deliver business improvements that stand the test of time. FREE! Go There Now!
| | | | Effective governance for lean development isn’t about command and control. Instead, the focus is on enabling the right behaviors and practices through collaborative and supportive techniques. Hear from Scott Ambler on how it is far more effective to motivate people to do the right thing than it is to force them to do so. Learn how to form a lightweight, collaboration-based framework that reflects the realities of modern IT organizations. FREE! Go There Now!
| | | | Visit IBM developerWorks to download IBM DB2 Express-C 9.5, a no-charge version of DB2 Express 9 database server. DB2 Express-C offers the same core data server base features as other DB2 Express editions and provides a solid base to build and deploy applications developed using C/C++, Java, .NET, PHP, and other programming languages. FREE! Go There Now!
| | | | Visit IBM developerWorks to download the latest trial version of IBM Data Studio V1.1 at no cost. IBM Data Studio is a comprehensive data management solution that helps you effectively design, develop, deploy and manage your data, databases, and database applications throughout the data management life cycle utilizing a consistent and integrated user interface. Unlike other client-side data management solutions that focus on only one aspect of the application lifecycle or database administration, Data Studio complements the Rational Software Delivery platform, providing unparalleled flexibility for a heterogeneous data server environment across platforms. FREE! Go There Now!
| | | | Download a free trial version of IBM Rational Developer for System z, software that can help you deliver core development capabilities; the power of Java Platform, Enterprise Edition (Java EE); and rapid application development support to diverse enterprise application development teams. With comprehensive development tools to help create, deploy and maintain traditional enterprise and composite applications, Rational Developer for System z enables developers with different technical backgrounds to easily participate in important technology projects. FREE! Go There Now!
| | | | IBM Enterprise Modernization solutions help organizations evolve core IT systems towards modern architectures and technologies—reducing the burden of maintenance and freeing up resources to develop new business requirements and capabilities. With the IBM Enterprise Modernization Sandbox for System z you can evaluate IBM Enterprise Modernization solutions focused on five key areas: Assets, Architectures, Skills, Processes and Infrastructures, and Investment. Each solution is based upon real customer experiences and offers a proven path to get you started with your modernization projects. FREE! Go There Now!
| | | | Rational Build Forge Express Edition is an automation framework that packages the latest enterprise-grade technologies into a reliable, flexible and robust configuration designed and priced specifically for small to midsize businesses. The new Rational Build Forge Express eKit provides you with valuable resources – including a case study, podcast, demo, and articles – to help you increase staff productivity, compress development cycles and deliver better software, fast. FREE! Go There Now!
| | | | Join this Rational Talks to You teleconference on December 11 at 1:00 pm ET to get tips on building your own plugins with Rational Method Composer. Get your questions answered! FREE! Go There Now!
| | | | Because access to government information continues to be an area of concern for many U.S. citizens with disabilities, the U.S. government enacted Section 508 of the Rehabilitation Act in 2001 to ensure that government agencies create accessible Web content, enabling all citizens to access the information they need. A fully accessible Web site makes Web content accessible to all individuals, including those with disabilities, who may be accessing Web content via a variety of user agents. Common user agents include standard Web browsers, text-only browsers, assistive devices and mobile devices such as cell phones or personal digital assistants (PDAs). FREE! Go There Now!
| | | | As businesses grow increasingly dependent upon Web applications, these complex entities grow more difficult to secure. Most companies equip their Web sites with firewalls, Secure Sockets Layer (SSL), and network and host security, but the majority of attacks are on applications themselves – and these technologies cannot prevent them. This paper explains what you can do to help protect your organization, and it discusses an approach for improving your organization’s Web application security. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |