private void btnDSLogin_Click(object sender, EventArgs e) { ActiveNetWanInfo wanInfo = new ActiveNetWanInfo(); wanInfo.iSize = Marshal.SizeOf(wanInfo); wanInfo.cWanIP = new char[32]; Array.Copy("192.168.2.18".ToCharArray(), wanInfo.cWanIP, "192.168.2.18".Length); wanInfo.iWanPort = 5555; IntPtr intptr1 = Marshal.AllocCoTaskMem(wanInfo.iSize); Marshal.StructureToPtr(wanInfo, intptr1, true);//false容易造成内存泄漏 int iRet = NVSSDK.NetClient_SetDsmConfig(0, intptr1, wanInfo.iSize); string strIP = txtDSAddress.Text; string strPort = txtDSPort.Text; string strUser = txtDSUserName.Text; string strPwd = txtDSPassword.Text; ActiveDirectoryInfo dsInfo = new ActiveDirectoryInfo(); dsInfo.iSize = Marshal.SizeOf(dsInfo); dsInfo.cDsmIP = new char[32]; Array.Copy(strIP.ToCharArray(), dsInfo.cDsmIP, strIP.Length); dsInfo.iDsmPort = Int32.Parse(strPort); dsInfo.cAccontName = new char[16]; Array.Copy(strUser.ToCharArray(), dsInfo.cAccontName, strUser.Length); dsInfo.cAccontPwd = new char[16]; Array.Copy(strPwd.ToCharArray(), dsInfo.cAccontPwd, strPwd.Length); IntPtr intptr = Marshal.AllocCoTaskMem(dsInfo.iSize); Marshal.StructureToPtr(dsInfo, intptr, true);//false容易造成内存泄漏 iRet = NVSSDK.NetClient_SetDsmConfig(1, intptr, dsInfo.iSize); }
public void SaveActiveDirectoryInfo(ActiveDirectoryInfo adInfo) { if (adInfo == null) { throw new ArgumentNullException("adInfo"); } new GenericData().Save(adInfo); }
public static void SaveActiveDirectoryInfo(ActiveDirectoryInfo adInfo) { if (adInfo == null) { throw new ArgumentNullException("adInfo"); } try { DataAccessFactory.GetDataInterface <ISecurityData>().SaveActiveDirectoryInfo(adInfo); } catch (ConcurrencyException ex) { LogicBase.SetConcurrencyUserSafeMessage(ex, adInfo.Id); throw; } }
public ActiveDirectoryInfo SaveActiveDirectoryInfo(ActiveDirectoryInfo adInfo) { Invoke(() => SecurityLogic.SaveActiveDirectoryInfo(adInfo)); return(adInfo); }