Thread Rating:
  • 204 Vote(s) - 2.56 Average
  • 1
  • 2
  • 3
  • 4
  • 5
他PCのディレクトリ指定時の認証について
04-01-2015, 12:15 PM,
#4
RE: 他PCのディレクトリ指定時の認証について
(03-24-2015, 12:43 PM)rom Wrote: net useを使用して接続する方法で動作しました!
しかし、Curl単体での認証は未だ出来ません。。。
何を以て「Curl単体」と言うのかよくわかりませんが、net コマンドの代わりに、DLL Interface で
WNetUseConnection() を呼び出すことで同じことはできます。

Code:
{import * from CURL.LANGUAGE.DLL-INTERFACE}

{define-C-struct public NetResource
    {defaults string-rep = CStringUTF16}
  ||--
  field public dwScope:int32
  field public dwType:int32
  field public dwDisplayType:int32
  field public dwUsage:int32
  field public lpLocalName:#String
  field public lpRemoteName:#String
  field public lpComment:#String
  field public lpProvider:#String
}

{define-dll-class public Mpr-dll
    {defaults
        calling-convention = stdcall,
        string-rep = CStringUTF16
    }

    {constructor public {default}
        {construct-super {SharedLibrary "mpr.dll"}}
    }

    || WNetUseConnection()
    {dll-method public {wnet-use-connection ("WNetUseConnectionW")
                           hwndOwner:CPointer,
                           lpNetResource:#NetResource,
                           lpPassword:#String,
                           lpUserID:#String,
                           dwFlags:int32,
                           lpAccessName:#{CArray-of byte},
                           lpBufferSize:{Reference-to int32},
                           lpResult:{Reference-to int32}
                       }:int
    }
}

{define-proc public {connect-remote-resource
                        remote:String,
                        user:#String = null,
                        password:#String = null
                    }:bool
    def dll = {Mpr-dll}
    
    def res = {NetResource}
    set res.dwScope = 0
    set res.dwType = 1        || RESOURCETYPE_DISK
    set res.dwDisplayType = 0 || RESOURCEDISPLAYTYPE_GENERIC
    set res.dwUsage = 0
    set res.lpLocalName = null
    set res.lpRemoteName = remote
    
    def length = 1024
    
    def flags = 8 || CONNECT_INTERACTIVE
    def access-name = {{CArray-of byte} length * 2} || wchar
    def buffer-size = {{Reference-to int32} value = length}
    def result = {{Reference-to int32}}

    def ret = {dll.wnet-use-connection
                  0,
                  res,
                  password,
                  user,
                  flags,
                  access-name,
                  buffer-size,
                  result
              }
    {return ret == 0}
}

上記の定義がある場合に、以下のようにプロシージャを呼び出すと、現在のアカウントで \\server\share に
接続します。現在のアカウントで認証できない場合は、認証ダイアログが表示されます。

Code:
{connect-remote-resource |"\\server\share"|}
Reply


Messages In This Thread
RE: 他PCのディレクトリ指定時の認証について - by imyme - 04-01-2015, 12:15 PM
Forum Jump:


Users browsing this thread:
1 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('1218')