作者: countmeon

  • 配置用户电话属性

    Const ADS_PROPERTY_UPDATE = 2
    Set objUser = GetObject _
    (“LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com”)

    objUser.Put “homePhone”, “(425) 555-1111”
    objUser.Put “pager”, “(425) 555-2222”
    objUser.Put “mobile”, “(425) 555-3333”
    objUser.Put “facsimileTelephoneNumber”, “(425) 555-4444”  
    objUser.Put “ipPhone”, “5555”
    objUser.Put “info”, “Please do not call this user account” & _
    ” at home unless there is a work-related emergency. Call” & _
    ” this user’s mobile phone before calling the pager number”

    objUser.PutEx ADS_PROPERTY_UPDATE, _
    “otherHomePhone”, Array(“(425) 555-1112”)
    objUser.PutEx ADS_PROPERTY_UPDATE, _
    “otherPager”, Array(“(425) 555-2223”)
    objUser.PutEx ADS_PROPERTY_UPDATE, _
    “otherMobile”, Array(“(425) 555-3334”, “(425) 555-3335”)
    objUser.PutEx ADS_PROPERTY_UPDATE, _
    “otherFacsimileTelephoneNumber”, Array(“(425) 555-4445”)
    objUser.PutEx ADS_PROPERTY_UPDATE, _
    “otherIpPhone”, Array(“6666”)
    objUser.SetInfo

  • 配置用户帐户的 Organization 属性

    Set objUser = GetObject _
        (“LDAP://cn=Myerken,ou=Management,dc=NA,dc=fabrikam,dc=com”)
       
    objUser.Put “title”, “Manager”
    objUser.Put “department”, “Executive Management Team”
    objUser.Put “company”, “Fabrikam”
    objUser.Put “manager”, _
        “cn=AckermanPilar,OU=Management,dc=NA,dc=fabrikam,dc=com”
    objUser.SetInfo

    Set objUser01 = GetObject _
        (“LDAP://cn=LewJudy,OU=Sales,dc=NA,dc=fabrikam,dc=com”)
    Set objUser02 = GetObject _
        (“LDAP://cn=AckersKim,OU=Sales,dc=NA,dc=fabrikam,dc=com”)
       
    objUser01.Put “manager”, objUser.Get(“distinguishedName”)
    objUser02.Put “manager”, objUser.Get(“distinguishedName”)

    objUser01.SetInfo
    objUser02.SetInfo

  • 清除 OU 的常规属性

    Const ADS_PROPERTY_CLEAR = 1
    Set objContainer = GetObject _
      (“LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com”)
     
    objContainer.PutEx ADS_PROPERTY_CLEAR, “description”, 0
    objContainer.PutEx ADS_PROPERTY_CLEAR, “street”, 0
    objContainer.PutEx ADS_PROPERTY_CLEAR, “l”, 0
    objContainer.PutEx ADS_PROPERTY_CLEAR, “st”, 0
    objContainer.PutEx ADS_PROPERTY_CLEAR, “postalCode”, 0
    objContainer.PutEx ADS_PROPERTY_CLEAR, “c”, 0
    objContainer.SetInfo

  • 清除 OU 的分区链接集

    Const ADS_PROPERTY_CLEAR = 1
    Set objContainer = GetObject _
      (“LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com”)
     
    objContainer.PutEx ADS_PROPERTY_CLEAR, “msCOM-UserPartitionSetLink”, 0

    objContainer.SetInfo

  • 从用户帐户中清除 COM+ 属性

    Const ADS_PROPERTY_CLEAR = 1

    Set objUser = GetObject _
        (“LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com”)
    objUser.PutEx ADS_PROPERTY_CLEAR, “msCOM-UserPartitionSetLink”, 0
    objUser.SetInfo

  • 从用户帐户中清除所有已发布证书

    Const ADS_PROPERTY_CLEAR = 1
    Set objUser = GetObject _
        (“LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com”)
    objUser.PutEx ADS_PROPERTY_CLEAR, “userCertificate”, 0
    objUser.SetInfo

  • 清除指派给 OU 的组策略链接

    Const ADS_PROPERTY_CLEAR = 1

    Set objContainer = GetObject _
    (“LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com”)
    objContainer.PutEx ADS_PROPERTY_CLEAR, “gPLink”, 0
    objContainer.PutEx ADS_PROPERTY_CLEAR, “gPOptions”, 0
    objContainer.SetInfo

  • 清除电话属性

    Const ADS_PROPERTY_CLEAR = 1

    Set objUser = GetObject _
    (“LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com”)

    objUser.PutEx ADS_PROPERTY_CLEAR, “info”, 0
    objUser.PutEx ADS_PROPERTY_CLEAR, “otherPager”, 0

    objUser.SetInfo

  • 清除属性

    Const ADS_PROPERTY_CLEAR = 1

    Set objUser = GetObject _
    (“LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com”)

    objUser.PutEx ADS_PROPERTY_CLEAR, “initials”, 0
    objUser.PutEx ADS_PROPERTY_CLEAR, “otherTelephone”, 0

    objUser.SetInfo

  • 更改组的作用域

    Const ADS_GROUP_TYPE_GLOBAL_GROUP = &h2
    Const ADS_GROUP_TYPE_LOCAL_GROUP = &h4
    Const ADS_GROUP_TYPE_UNIVERSAL_GROUP = &h8
    Const ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000

    Set objGroup = GetObject _
       (“LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com”)
    objGroup.Put “groupType”, _
      ADS_GROUP_TYPE_GLOBAL_GROUP + ADS_GROUP_TYPE_SECURITY_ENABLED
     
    objGroup.SetInfo

  • 更改 OU 的管理者

    Set objContainer = GetObject _ (“LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com”) objContainer.Put “managedBy”, “cn=AkersKim,ou=Sales,dc=NA,dc=fabrikam,dc=com” objContainer.SetInfo

  • 更改 Windows 本地管理员密码

    strComputer = “MyComputer”
    Set objUser = GetObject(“WinNT://” & strComputer & “/Administrator, user”)
    objUser.SetPassword “testpassword”
    objUser.SetInfo

  • 更改用户帐户属性

    Const ADS_PROPERTY_UPDATE = 2
    Set objUser = GetObject _
    (“LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com”)

    objUser.Put “givenName”, “Ken”
    objUser.Put “initials”, “E.”
    objUser.Put “sn”, “Myer”
    objUser.Put “displayName”, “Myer, Ken”
    objUser.Put “physicalDeliveryOfficeName”, “Room 4358”
    objUser.Put “telephoneNumber”, “(425) 555-1211”
    objUser.Put “mail”, “myerken@fabrikam.com”
    objUser.Put “wWWHomePage”, “http://www.fabrikam.com”

    objUser.PutEx ADS_PROPERTY_UPDATE, _
    “description”, Array(“Management staff”)
    objUser.PutEx ADS_PROPERTY_UPDATE, _
    “otherTelephone”, Array(“(800) 555-1212”, “(425) 555-1213”)
    objUser.PutEx ADS_PROPERTY_UPDATE, _
    “url”, Array(“http://www.fabrikam.com/management”)

    objUser.SetInfo

  • 将发布的证书分配给 Active Directory 用户帐户

    On Error Resume Next
    Const ADS_PROPERTY_UPDATE = 2

    Set objUserTemplate = _
        GetObject(“LDAP://cn=userTemplate,OU=Management,dc=NA,dc=fabrikam,dc=com”)
    arrUserCertificates = objUserTemplate.GetEx(“userCertificate”)

    Set objUser = _
        GetObject(“LDAP://cn=MyerKen,OU=Management,dc=NA,dc=fabrikam,dc=com”)
    objUser.PutEx ADS_PROPERTY_UPDATE, “userCertificate”, arrUserCertificates
    objUser.SetInfo

  • 指派组管理者

    Set objGroup = GetObject _
      (“LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com”)
     
    objGroup.Put “managedBy”, “cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com”
    objGroup.SetInfo

  • 将住宅电话号码附加到 Active Directory 用户帐户

    Const ADS_PROPERTY_APPEND = 3

    Set objUser = GetObject _
       (“LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com”)
    objUser.PutEx ADS_PROPERTY_APPEND, “otherHomePhone”, Array(“(425) 555-0116”)
    objUser.SetInfo

  • AirKen远程程序

    关于远程软件的说明

    1.这是给有网络维护经验的人用的,所以必须具备基本网络知识才用
    2.不会用不要找我咨询了,有时候太没时间了.
    3.我只简单说一下部署方法,看不懂我也没办法了.

      以前经常用QQ远程给朋友和客户处理问题,QQ远程有时候真的很不好用,太慢,使用专业的远程又需要教用户下载不小的客户端,还有想办法让他设置好了,好让我连接到他.实在是痛苦极了.现在做这个程序就是为了在QQ远程不能用的情况下怎么最简单的能远程并处理好他电脑的故障.为达到这个目的,我必须把所有设置在本机上完成,给用户只需要运行客户端就行了,为了透过对方的普通防火墙,采用的反向链接,由客户端连接我,所以软件控制方面的可操作性比较差,这到不要紧,我只要能排除他的电脑故障,这才是我的目的.
      好了,到底如何设置呢?现在我来简单的说一下
      首先客户端文件夹下有客户端程序和设置文件Set.ini,我需要替用户设置好设置,打开这个文件,
        IP: 这个填写我现在这台电脑的外网IP,如果不知道装个花生壳,填写你的花生壳域名也行,如果不想装那就在google搜索一下 外网IP ,然后可以查到你的外网IP.
        端口和自动运行不用改
        本机标识是对客户端的一个识别,如果同时远程几个客户端那这个标识要不同才行
      说到这里客户端就设置玩了,我们可以把整个客户端文件夹打成rar包,然后发给用户,让他运行里面的 AirKen远程.exe 程序.
     
      我自己这里怎么设置呢?就是使互联网上的那个客户端能访问到你就行了,一般你的防火墙要放行 AirKen远程协助.exe 这个程序,不能让自己的防火墙给拦截了.如果是直接ADSL拨号那就可以了,如果是路由上网,那还必须在路由上设置端口映射,把默认9019这个端口的数据映射到你的这台电脑上就行了.

      完了,使用愉快!

  • AU3域环境中普通用户安装软件

    #Region ;**** 参数创建于 ACNWrapper_GUI ****
    #AutoIt3Wrapper_outfile=..\桌面\安装程序.exe
    #EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Include <Array.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate(“安装软件列表”, 193, 151, 490, 274)
    $Combo1 = GUICtrlCreateCombo(“请选择安装的文件”, 24, 40, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Button1 = GUICtrlCreateButton(“安装”, 56, 96, 75, 25)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    $username=”administrator”        ;定义安装程序账号
    $domain=”yourdomain”              ;定义账号所在域 或者计算机名
    $password= “yourpassword”  ;定义账号密码
    $path=”D:\test\setup.ini”;定义安装软件目录文件
    ;———————————————————————-
    Dim $str  ;定义下拉列表变量
    $var = IniReadSection($path, “config”)  ;获取ini文件内容到数组
    If @error Then
        MsgBox(4096, “”, “错误, 读取INI文件失败.”)
    Else
        For $i = 1 To $var[0][0]
             $str &= $var[$i][0]&”|”
        Next
    EndIf
    GUICtrlSetData($Combo1 ,$str, “”) ; 赋值给下拉列表
    ;———————————————————————-

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button1
                setup()
        EndSwitch
    WEnd
    Func setup ()
       $name=GUICtrlRead($Combo1)
       $exe = IniRead($path, “config”, $name, “NotFound”)
       Local $pid = RunAsWait( $username,$domain , $password,1, $exe , @ScriptDir )
       ProcessWaitClose($pid)
    EndFunc

  • 用AutoIt实现受限用户“运行方式”自动输入密码

    随着NTFS权限安全设置被越来越多人认识。计算机用户为了机器的安全,日常使用电脑时不再以管理员账号登录电脑,而以受限用户账号登录电脑。当需要更改硬件或安装软件时,才以管理员账号登录。
     
    这样可以使电脑更安全,以受限用户账号登录电脑,即使电脑使被病毒感染,病毒也不能破坏WINDOWS系统文件,只能感染当前用户文件。因为受限用户没有权限对系统文件做任何更改,只能对自己的文件做更改。

     

     

    但有些程序在受限用户下无法正常使用,需要管理员权限。此时只能右键——“运行方式”,以管理员身份运行程序。显得不太方便。

     
    1、每次运行程序都要输入管理员密码。

     
    2、不想让受限用户知道密码。(自己又不能随时侍在电脑旁边,给使用者输入密码)

     

     

    不过AutoIt这个程序能够帮助解决这个问题,它能够实现自动填充密码。

     
    下载网址http://www.autoitscript.com/autoit3/index.shtml

     

     

    安装后,打开编辑器SciTE Script Editor,新建文件,开始编辑程序运行脚本

     
    RunAs(“用户名”,“电脑名”,“用户密码”,0,“程序路径及名称”,“程序开始工作目录”)

     
    例如打开记事本:

     
    RunAs(“用户名”,“电脑名”,“用户密码”,0,“C:\WINDOWS\notepad.exe”,“C:\WINDOWS\”)

     
    保存成文件“打开记事本.au3”后,打开编译器Compile Script to .exe,把 “打开记事本.au3” 编译成 “打开记事本.exe”

     
    这样以点击“打开记事本.exe”,就是以管理员身份执行notepad.exe,可以打开保存任意文档。

     

     

    “打开记事本.exe”会自动以管理员身份运行notepad.exe,并且会自动填写管理员密码。只要管理员账号、密码不变动,就能一直使用。

     
    当然可以用加密文本储存账号、密码、运行程序 等参数,程序根据加密文本执行程序。当有参数变更时,变更加密文本就行了。

     
    这个可以根据个人需要,自己开发。

     

     

    另一个要注意的是参数: 0 和 “程序开始工作目录”,一般用 0 和 程序所在目录
     
    详细使用方法,可以看AutoIt自带的帮助说明中RunAs,内容如下:

     
    RunAs

    ——————————————————————————–

    Runs an external program under the context of a different user.
     
    RunAs ( “username”, “domain”, “password”, logon_flag, “program” [, “workingdir” [, show_flag [, opt_flag ]]] )
     
     
     
    Parameters
     

    username
     
    The username to log on with.

     

    domain
     
    The domain to authenticate against.

     

    password
     
    The password for the user.

     

    logon_flag
     
    0 – Interactive logon with no profile.
    1 – Interactive logon with profile.
    2 – Network credentials only.
    4 – Inherit the calling processes environment instead of the user’s.

     

    program
     
    The full path of the program (EXE, BAT, COM, or PIF) to run (see remarks).

     

    workingdir
     
    [optional] The working directory. If not specified, then the value of @SystemDir will be used. This is not the path to the program.

     

    show_flag
     
    [optional] The “show” flag of the executed program:
      @SW_HIDE = Hidden window (or Default keyword)
      @SW_MINIMIZE = Minimized window
      @SW_MAXIMIZE = Maximized window

     

    opt_flag
     
    [optional] Controls various options related to how the parent and child process interact.
      0x1 ($STDIN_CHILD) = Provide a handle to the child’s STDIN stream
      0x2 ($STDOUT_CHILD) = Provide a handle to the child’s STDOUT stream
      0x4 ($STDERR_CHILD) = Provide a handle to the child’s STDERR stream
      0x8 ($STDERR_MERGED) = Provides the same handle for STDOUT and STDERR. Implies both $STDOUT_CHILD and $STDERR_CHILD.
      0x10 ($STDIO_INHERIT_PARENT) = Provide the child with the parent’s STDIO streams. This flag can not be combined with any other STDIO flag. This flag is only useful when the parent is compiled as a Console application.
      0x10000 ($RUN_CREATE_NEW_CONSOLE) = The child console process should be created with it’s own window instead of using the parent’s window. This flag is only useful when the parent is compiled as a Console application.

     
     
     
    Return Value
     

    Success:
     
    The PID of the process that was launched.

     

    Failure:
     
    Returns 0 and sets @error to non-zero.

     
     
     
    Remarks
    Paths with spaces need to be enclosed in quotation marks.

    It is important to specify a working directory the user you are running as has access to, otherwise the function will fail.

    It is recommended that you only load the user’s profile is you are sure you need it. There is a small chance a profile can be stuck in memory under the right conditions. If a script using RunAs() happens to be running as the SYSTEM account (for example, if the script is running as a service) and the user’s profile is loaded, then you must take care that the script remains running until the child process closes.

    When running as an administrator, the Secondary Logon (RunAs) service must be enabled or this function will fail. This does not apply when running as the SYSTEM account.

    After running the requested program the script continues. To pause execution of the script until the spawned program has finished use the RunAsWait function instead.

    Providing the Standard I/O parameter with the proper values permits interaction with the child process through the StderrRead, StdinWrite and StdoutRead functions. Combine the flag values (or use $STDERR_CHILD, $STDIN_CHILD & $STDOUT_CHILD, defined in Constants.au3) to manage more than one stream.

    In order for the streams to close, the following conditions must be met: 1) The child process has closed it’s end of the stream (this happens when the child closes). 2) AutoIt must read any captured streams until there is no more data. 3) If STDIN is provided for the child, StdinWrite() must be called to close the stream. Once all streams are detected as no longer needed, all internal resources will automatically be freed.
    StdioClose can be used to force the STDIO streams closed.

    The “load profile” and “network credentials only” options are incompatible. Using both will produce undefined results.

    There is an issue in the Windows XP generation of Windows which prevents STDIO redirection and the show flag from working. See Microsoft Knowledge Base article KB818858 for more information about which versions are affected as well as a hotfix for the issue. User’s running Windows 2000, Windows XP SP2 or later, or Windows Vista are not affected.

  • 在网页中嵌入word、excel、pdf的注意事项

    网上此类代码非常多,无非以下几个
    嵌入pdf有两种方式
    1 用object嵌入方式

    <object classid=”clsid:CA8A9780-280D-11CF-A24D-444553540000″ width=”760″ height=”411″ border=”0″>
    <param name=”SRC” value=”<%=request.getContextPath()%>/xxx.pdf”>
    </object>

    2 直接写代码

    <iframe src=”a.pdf”></iframe>

    嵌入word或excel,有类似object控件,但是似乎都是收费的,所以只能用

    <iframe src=”a.doc”></iframe>

    应注意问题:
    1 用object方式嵌入pdf,src可以用一个url来代替,就想下载文件的代码;
    2 当用iframe嵌入pdf或者word、excel时,如果采用流输出方式,那么会刷新整个浏览器,而不是那个iframe区域;
    3 如果你的浏览器每次都是弹出下载pdf或者doc等文件,那么请检查如下几个地方
    a 如果采用流输出方式,请注意content-type设置是否正确,比如pdf是application/pdf,doc是application/msword,xls是application/vnd.ms-excel;
    b 如果直接连接的文件,比如pdf,那么需要卸载adobe pdf,然后重新安装;office的版本应该是2003.
    4 关于中文文件,需要进行编码,<%=URLEncoder.encode(“pdf文件名”) %>