`
lovnet
  • 浏览: 6920263 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
文章分类
社区版块
存档分类
最新评论

SMS脚本节选一:连接到SMS Provider

阅读更多

Before connecting to the SMS Provider for a local or remote SMS site server, you first need to locate the SMS Provider for the site server. The SMS Provider can be either local or remote to the SMS site server you are using. The WMI class SMS_ProviderLocation is present on all SMS site servers, and one instance will contain the location for the SMS site server you are using.

You can connect to the SMS Provider on an SMS site server by using the WMI <linktext xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></linktext>SWBemLocator object or by using the Windows Script Host GetObject method. Both approaches work equally well on local or remote connections, with the following limitations:

  • You must use SWbemLocator if you need to pass user credentials to a remote computer.

  • You cannot use SWBemLocator to explicitly pass user credentials to a local computer.

There are several different syntaxes that you can use to make the connection, depending on whether the connection is local or remote. The following procedures provide two common variations. After you are connected to the SMS Provider, you will have an <linktext xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></linktext>SWBemServices object that you use to access SMS objects.

To connect to an SMS Provider by using SWbemLocator

  1. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Connect to the local SWbemLocator object:

    set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
  2. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Connect to a known SMS site server. If the computer name is a remote computer, you can pass the user name and password. Alternatively, you can authenticate using the current user's credentials by removing the user name and password parameters. If the computer name is the local computer, you must remove the user name and password because these will not be accepted. You can also change the computer name to "." if you want to connect to the local computer.

    set objSWbemServices= objSWbemLocator.ConnectServer _
        ("ComputerName", "root\sms","username","password")
  3. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Locate the SMS Provider for the SMS site by inspecting the SMS_ProviderLocation WMI class. For the SMS_ProviderLocation instance where the ProviderForLocalSite property is true, the object's Machine and SiteCode properties give the location of the SMS Provider for the SMS site server you are connected to. If the account running the script on the local computer has appropriate privileges, the user name and password parameters can be omitted.

    Set ProviderLoc = objSWbemServices.InstancesOf("SMS_ProviderLocation")
    
    For Each Location In ProviderLoc
            If Location.ProviderForLocalSite = True Then
                Set objSWbemServices = objSWbemLocator.ConnectServer _
                     (Location.Machine, "root\sms\site_" + Location.SiteCode,"username","password")
            End If
    Next
  4. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Continue using the objSWbemServices object to access SMS objects.

To connect to a remote SMS Provider by using the GetObject method

  1. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Connect to a known SMS site server by using GetObject. In this example, authentication is set to impersonate. If you are connecting to the local computer, you can change SERVERNAME to ".".

    Set objSWbemServices = GetObject("winmgmts:{impersonationLevel=impersonate}!\\SERVERNAME\root\sms\site_SITECODE")
    if err.number<>0 then
        wscript.echo "WBemServices connection failed"
        wscript.quit
    end if
    
  2. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Continue using the objSWbemServices object to access SMS objects.

Security

<content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

Using script to pass the user name and password is a security risk and should be avoided where possible.

分享到:
评论

相关推荐

    sms.rar_T3_sms_sms 接收_短信接收

    标题中的“sms.rar_T3_sms_sms 接收_短信接收”表明这是一个关于短信接收的程序,主要用于T35i设备。这个程序具有处理和转发短信的功能,它通过UDP(User Datagram Protocol)协议来实现数据传输。 描述部分进一步...

    短信猫二次开发包动态连接DLL接口——VB

    将sms.dll文件拷贝到系统安装目录中的system32文件夹中,然后再根据以下接口函数说明和提供的例程源码开发 接口函数: 1、Sms_Connection(Com_Port As Integer,Com_BaudRate As Integer, Mobile_Type As String)...

    微软 SMS2003 教程 SMS 教程 PDF SMS内部资料 SMS部署详解 SMS部署方法 sms手册

    5. **客户端部署**:通过GPO、手动安装或脚本等方式将SMS客户端部署到目标机器。 6. **配置和测试**:设置策略、软件分发和更新规则,进行测试以验证功能正常。 7. **监控与维护**:持续监控系统性能,及时处理...

    短信猫二次开发包动态连接DLL接口——Delphi

    将sms.dll文件拷贝到系统安装目录中的system32文件夹中,然后再根据以下接口函数说明和提供的例程源码开发 接口函数: 1、Sms_Connection(Com_Port As Integer,Com_BaudRate As Integer, Mobile_Type As String)...

    android SMS

    在Android平台上,短信服务(SMS)是移动应用开发中的一个重要组成部分,它允许用户发送和接收文本消息。在本文中,我们将深入探讨如何在Android中实现短信功能,包括相关的API、权限管理、创建发送短信的Intent以及...

    EasySMS发送短信最简单的方法

    EasySMS 是一个基于 PHP 的短信发送库,设计用于简化企业或开发者向用户发送短信的过程。在 PHP 开发中,有时我们需要实现发送验证码、通知...如果你的项目涉及到短信发送功能,那么 EasySMS 绝对值得你考虑和采用。

    Laravel开发-laravel-sms-api

    SMS::send($recipient, $message, ['provider' =&gt; 'twilio']); } ``` 为了接收短信,laravel-sms-api通常依赖于HTTP回调,这意味着短信服务提供商在发送短信后会向你的应用发送一个HTTP请求。你需要创建一个路由来...

    eucp-sms-sdk.zip

    亿美短信发送SDK是一款专为开发者设计的工具,用于集成到各类应用程序中,实现快速、稳定、高效地发送短信功能。这款SDK以其简洁的接口、丰富的功能和良好的兼容性,深受广大开发者的青睐。本文将详细介绍亿美短信...

    短信猫多种语言通用开发程序

    function Sms_Send(Sms_TelNum:string;Sms_Text:string):integer;stdcall;external 'sms.dll'; Function Sms_Receive(Sms_Type:string;var Sms_Text:PChar):integer;stdcall;external 'sms.dll'; function Sms_...

    SMS.rar_android_android sms.zip_sms_sms android_sms java

    在Android平台上,短信服务(SMS)是移动应用开发中的一个重要组成部分。这个压缩包"SMS.rar"和"android_android sms.zip"包含的可能是一系列与在Android系统上编程短信功能相关的资源和代码示例。让我们深入探讨...

    sms2mikeV4.1_by火鸟1412.rar

    总的来说,"sms2mikeV4.1_by火鸟1412"作为一个实用的第三方工具,有效连接了SMS和Mike21,实现了数据的无缝对接,极大地便利了水动力学模型的跨软件应用。对于从事相关领域的工程师和技术人员来说,掌握这个工具的...

    Laravel开发-laravel-sms

    SMS::send('recipient_number', 'Hello, world!', function ($message) { $message-&gt;from('your_twilio_number'); }); ``` `laravel-sms` 还提供了批量发送、模板消息、短信队列等功能,以满足不同场景的需求。...

    SMSPDU 短信转化

    在OpenWRT环境中,通过3G/4G Dongle发送短信涉及到的是移动通信技术中的SMSPDU(Short Message Service Protocol Data Unit,短信协议数据单元)知识。SMSPDU是GSM网络中短信服务的一种底层协议格式,用于在手机和...

    短信猫二次开发包动态连接DLL接口——PB

    将sms.dll文件拷贝到系统安装目录中的system32文件夹中,然后再根据以下接口函数说明和提供的例程源码开发 接口函数: 1、Sms_Connection(Com_Port As Integer,Com_BaudRate As Integer, Mobile_Type As String)...

    Sms.rar_MMS_android sms_android 短信_sms_sms android

    3. **短信监听**: 若要监听接收到的短信,需创建一个继承自`BroadcastReceiver`的类,并在`onReceive()`方法中处理`Intent.ACTION_SMS_RECEIVED`广播。注册该广播接收器时,也需要声明`RECEIVE_SMS`权限。 4. **...

    Sms.rar_PDU编码_pdu_sms c_sms pdu_sms 解码

    PDU模式是SMS的一种传输格式,用于在移动设备之间传递短信。在这个主题中,"Sms.rar_PDU编码_pdu_sms c_sms pdu_sms 解码",我们将深入探讨PDU编码和解码的过程,以及如何在C语言环境下实现这个功能。 PDU编码是将...

    sms.zip_Android 数据库_android_android sms_sms

    2. **Android SMS管理**:Android系统中的短信管理涉及到两个主要组件:SMS Provider和BroadcastReceiver。SMS Provider是一个内容提供者,它允许应用程序通过ContentResolver访问和修改短信数据。BroadcastReceiver...

    SMS 和 CRM:演变过程中的相似之处和相反之处.pdf

    SMS是一种系统性的方法,旨在识别和控制安全风险,通过持续监控和改进来确保飞行安全。SMS的核心要素包括安全政策、安全风险管理、安全保证以及安全促进四个方面。 - **安全政策**:明确组织的安全目标与承诺。 - *...

    安卓Android源码——sms1.rar

    在 Android 系统中,短信服务(SMS)是核心功能之一,它允许用户发送、接收和管理文本消息。本文将深入探讨 Android 源码中的短信实现,主要关注 SMS 相关的组件、数据存储以及 API 使用。 1. **短信服务组件**: ...

Global site tag (gtag.js) - Google Analytics