andrea...@gmail.com
unread,Feb 23, 2012, 6:51:08 AM2/23/12You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
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(
[MarshalAs(UnmanagedType.LPWStr)]
string DfsEntryPath,
[MarshalAs(UnmanagedType.LPWStr)]
string ServerName,
[MarshalAs(UnmanagedType.LPWStr)]
string PathName,
[MarshalAs(UnmanagedType.LPWStr)]
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(
[MarshalAs(UnmanagedType.LPWStr)]
string DfsEntryPath,
[MarshalAs(UnmanagedType.LPWStr)]
string ServerName,
[MarshalAs(UnmanagedType.LPWStr)]
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);
Console.WriteLine(res);
//0, but the referral cache value is still 300
Marshal.FreeHGlobal(timeoutBuffer);
Please help!!!!!!!