我从msdn站点找到了一些代码(下面包含代码),看起来它将返回给定服务器的所有dns别名.我已经在cosole应用程序中实现了代码,这应该允许我输入服务器的主机名,它应该返回所有dns别名.我在我们的域中输入已知具有别名的服务器的主机名(我可以ping主机和别名,它们都解析为相同的IP),但是此代码找不到别名.显然我对dns别名和/或代码的理解不足...请教育我...
static void Main(string[] args)
{
Console.Write("Host? (Enter for local): ");
string strHost = Console.ReadLine();
if (strHost.Trim().Length == 0)
{
strHost = System.Net.Dns.GetHostName();
}
try
{
//System.Net.IPAddress hostIPAddress = System.Net.IPAddress.Parse(strHost);
System.Net.IPHostEntry hostInfo = System.Net.Dns.GetHostByName(strHost);//.GetHostByAddress(hostIPAddress);
// Get the IP address list that resolves to the host names contained in
// the Alias property.
System.Net.IPAddress[] address = hostInfo.AddressList;
// Get the alias names of the addresses in the IP address list.
String[] alias = hostInfo.Aliases;
Console.WriteLine("Host name : " + …Run Code Online (Sandbox Code Playgroud) 是否可以使用正则表达式将每个单词的第一个字符大写?
我将在VB.net(SSIS)中使用它
而不是使用Dictionary<TKey,TValue>我想要某种类型的集合类,可以使用值的属性作为键,是否有这样的东西?
我的控制器中有一个用于HttpPost的创建操作.在该操作中,我在db中插入记录,然后返回一个指定不同操作名称的视图,因为我想将用户带到其他地方,例如他们刚创建的记录的详细信息视图,然后我传入当前模型,所以我不必重新加载他们刚刚输入的数据.不幸的是,地址栏中的网址仍然显示原始的创建操作.
[HttpPost]
public ActionResult Create(MyModel model)
{
//Insert record
...
//Go to details view, pass the current model
//instead of re-loading from database
return View("Details", model);
}
Run Code Online (Sandbox Code Playgroud)
如何让网址显示" http:// myapp/MyController/Details/1 ",而不是" http:// myapp/MyController/Create/1 "?是可能的,还是我必须进行重定向?我希望我可以避免重定向......
如果我有一台打印机直接连接到电脑(带打印机的信息亭),我将如何创建网页(.net网络应用程序)打印jpg到信息亭打印机的能力,除了用户干预除了点击页面上的按钮?
如果您有一位负责在实时环境中部署数据库的DBA,您会选择给他什么?他可以恢复到现有数据库的数据库创建脚本或备份?有哪些优点/缺点?(我们使用的是MSSQL2000和MSSQL2005)
我在Windows机器上有一个java应用程序,它不时地引导CPU.想运行一个实用程序来了解应用程序正在创建多少线程等.有没有这样的实用工具?
我试图通过视觉定位实体来展示彼此之间的关系.看起来像自动图形布局,弹簧算法将满足我的需要.我想使用c#在silverlight中实现它,所以我正在寻找代码示例,或者链接到理论的良好解释.任何帮助赞赏
I am using the win32 PrintWindow function to capture a screen to a BitMap object.
If I only want to capture a region of the window, how can I crop the image in memory?
Here is the code I'm using to capture the entire window:
[System.Runtime.InteropServices.DllImport(strUSER32DLL, CharSet = CharSet.Auto, SetLastError = true)]
public static extern int PrintWindow(IntPtr hWnd, IntPtr hBltDC, uint iFlags);
public enum enPrintWindowFlags : uint
{
/// <summary>
///
/// </summary>
PW_ALL = 0x00000000,
/// <summary>
/// Only …Run Code Online (Sandbox Code Playgroud) 在Web应用程序中,我们希望显示属于特定组成员的用户的sam帐户列表.在许多情况下,组可以有500个或更多成员,我们需要页面响应.
一组约500名成员需要7-8秒才能获得该组所有成员的sam帐户列表.有更快的方法吗?我知道Active Directory管理控制台会在一秒钟内完成它.
我尝试过几种方法:
1)
PrincipalContext pcRoot = new PrincipalContext(ContextType.Domain)
GroupPrincipal grp = GroupPrincipal.FindByIdentity(pcRoot, "MyGroup");
List<string> lst = grp.Members.Select(g => g.SamAccountName).ToList();
Run Code Online (Sandbox Code Playgroud)
2)
PrincipalContext pcRoot = new PrincipalContext(ContextType.Domain)
GroupPrincipal grp = GroupPrincipal.FindByIdentity(pcRoot, "MyGroup");
PrincipalSearchResult<Principal> lstMembers = grp.GetMembers(true);
List<string> lst = new List<string>();
foreach (Principal member in lstMembers )
{
if (member.StructuralObjectClass.Equals("user"))
{
lst.Add(member .SamAccountName);
}
}
Run Code Online (Sandbox Code Playgroud)
3)
PrincipalContext pcRoot = new PrincipalContext(ContextType.Domain)
GroupPrincipal grp = GroupPrincipal.FindByIdentity(pcRoot, "MyGroup");
System.DirectoryServices.DirectoryEntry de = (System.DirectoryServices.DirectoryEntry)grp.GetUnderlyingObject();
List<string> lst = new List<string>();
foreach (string sDN in de.Properties["member"]) …Run Code Online (Sandbox Code Playgroud) .net ×4
c# ×4
alias ×1
asp.net ×1
asp.net-mvc ×1
collections ×1
deployment ×1
dictionary ×1
dns ×1
graph ×1
graph-theory ×1
java ×1
javascript ×1
printing ×1
process ×1
regex ×1
silverlight ×1
sql ×1
sql-server ×1
ssis ×1
vb.net ×1
winapi ×1