Rodrigo Verissimo
2005-03-01 19:02:57 UTC
Hi groups, i am trying to create a little app used to force the use of a
specified DFS root referral. I have seen people advising that it could be
done, However i am trying to do wrap this function in VB.
However i always get error 2662 " There is no DFS name whose entry path
matches the input Entry Path"
strings need to be wide so i use strconv, besides this strinc to pointer
conversion is implicit so i don't see what i am missing...
Thanksfor any assistance.
Here is the code :
Private Declare Function NetDfsSetClientInfo Lib "netapi32.dll" ( _
ByVal DfsEntryPath As String, _
ByVal servername As String, _
ByVal ShareName As String, _
ByVal level As Long, _
ByRef Buffer As DFS_INFO_101) As Long
Private Type DFS_INFO_101
State As Long
End Type
Private Sub Form_Load()
Dim stateDFS As DFS_INFO_101
stateDFS.State = 4
' 4 means ACTIVE
Dim rootdfs As String
Dim serverdfs As String
Dim targetdfs As String
Dim ret as long
rootdfs = \\domain.com\dfsrootname
serverdfs = "server"
targetdfs = \\server\roottarget
rootdfs = StrConv(", vbUnicode)
serverdfs = StrConv(serverdfs, vbUnicode)
targetdfs = StrConv(targetdfs, vbUnicode)
ret = NetDfsSetClientInfo(rootdfs, serverdfs, targetdfs, 101, stateDFS)
End sub
specified DFS root referral. I have seen people advising that it could be
done, However i am trying to do wrap this function in VB.
However i always get error 2662 " There is no DFS name whose entry path
matches the input Entry Path"
strings need to be wide so i use strconv, besides this strinc to pointer
conversion is implicit so i don't see what i am missing...
Thanksfor any assistance.
Here is the code :
Private Declare Function NetDfsSetClientInfo Lib "netapi32.dll" ( _
ByVal DfsEntryPath As String, _
ByVal servername As String, _
ByVal ShareName As String, _
ByVal level As Long, _
ByRef Buffer As DFS_INFO_101) As Long
Private Type DFS_INFO_101
State As Long
End Type
Private Sub Form_Load()
Dim stateDFS As DFS_INFO_101
stateDFS.State = 4
' 4 means ACTIVE
Dim rootdfs As String
Dim serverdfs As String
Dim targetdfs As String
Dim ret as long
rootdfs = \\domain.com\dfsrootname
serverdfs = "server"
targetdfs = \\server\roottarget
rootdfs = StrConv(", vbUnicode)
serverdfs = StrConv(serverdfs, vbUnicode)
targetdfs = StrConv(targetdfs, vbUnicode)
ret = NetDfsSetClientInfo(rootdfs, serverdfs, targetdfs, 101, stateDFS)
End sub