NetDfsSetClientInfo doesn't work properly

Skip to first unread message

Feb 23, 2012, 6:51:08 AM2/23/12
Hi everybody,
I'm trying to do make a simple API call to modify the DFS cache referral... return code is 0, but no change is persisted. Following the code... There is any point I'm missing?

[DllImport("Netapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern int NetDfsAdd(
string DfsEntryPath,
string ServerName,
string PathName,
string Comment,
int Flags);

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
private struct DFS_INFO_102
public ulong Timeout;

[DllImport("Netapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int NetDfsSetClientInfo(
string DfsEntryPath,
string ServerName,
string PathName,
int Level,
IntPtr Buffer);

//some other code

DFS_INFO_102 info;
info.Timeout = 1800;
IntPtr timeoutBuffer = IntPtr.Zero;
timeoutBuffer = Marshal.AllocHGlobal(Marshal.SizeOf(info));
Marshal.StructureToPtr(info, timeoutBuffer, false);

NetDfsAdd("\\\\MyDomain\\DFS\\PathToLink", share, folder, "My link", 1);
//Successfully created the dfs entry, but the referral cache is set to
//300 sec.

int res = NetDfsSetClientInfo("\\\\MyDomain\\DFS\\PathToLink", null, null, 102, timeoutBuffer);
//0, but the referral cache value is still 300


Please help!!!!!!!
Message has been deleted

Feb 28, 2012, 5:09:29 AM2/28/12
Solved by myself, in order to reach the goal the correct method to be invoked is NetDfsSetInfo.
Reply all
Reply to author
0 new messages