- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我需要创建一个有效的 jqTree来自 Active Directory OU 的 JSON 结构。我正在为此使用递归方法 (InfoNode) 进行测试,但我无法获取它。
生成的 json 进入字符串 json。要处理的第一个节点是具有默认域根的 DirectoryEntry 父节点。递归方法(InfoNode)得到当前子节点,按“OU”过滤并创建 JSON 属性“label”和“path”。 Before 检查此节点是否有更多子节点写入当前 JSON 项目的末尾。最后,如果有更多的 child ,再次运行方法(InfoNode):
public static DirectoryEntry root = new DirectoryEntry("LDAP://RootDSE");
public string dom = (string)root.Properties["defaultNamingContext"].Value;
public string json = "";
public Form1()
{
InitializeComponent();
DirectoryEntry parent = new DirectoryEntry("LDAP://" + dom);
InfoNode(parent);
System.IO.File.WriteAllText(@"json.txt", json);
}
void InfoNode(DirectoryEntry node)
{
string[] arr = node.Name.Split('=');
if (arr[0] == "OU")
{
json += "'children':[{'label':'" + arr[1] + "','path':'" + node.Path + "'";
if (nodo.Children == null)
{
json += "}]";
}
else
{
json += ",";
}
}
if (node.Children != null)
{
foreach (DirectoryEntry child in node.Children)
{
InfoNode(child);
}
}
}
最佳答案
您应该提供有关代码失败原因的更多详细信息。
我会试一试 :-)
您可以尝试修改您的代码,如下所示。不是最优的(在拆分之前使用 startswith,更多的 string.Format,在递归调用方法之前使用 startswith 测试 child 会更好),但我想它应该可以工作。
当您在树中前进时,您可能需要从 ldap 源加载子项。
public string json = "";
public Form1()
{
InitializeComponent();
DirectoryEntry parent = new DirectoryEntry("LDAP://" + dom);
json = InfoNode(parent);
System.IO.File.WriteAllText(@"json.txt", json);
}
public string InfoNode(DirectoryEntry node)
{
string[] arr = node.Name.Split('=');
var result = string.Empty;
if (arr[0].Equals("ou",StringComparison.InvariantCultureIgnoreCase))
{
result = "'{'label':'" + arr[1] + "','path':'" + node.Path + "'";
if (node.Children.Cast<DirectoryEntry>().Any())
{
result += String.Format(", children:[{0}]",
String.Join(",\n ",
node.Children.Cast<DirectoryEntry>()
.Select(InfoNode).Where(s=>!string.IsNullOrEmpty(s))
.ToArray()));
}
result += "}";
}
return result;
}
关于c# - Active Directory OU 树到 jqTree,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13700814/
我想输出测试 OU 中的所有 OU。 my $mesg = $ldap->search( base => "OU=test,OU=company,DC=example,DC=com",
我正在寻找一个 PowerShell 脚本,它可以帮助我: OU 的名称 每个OU 中 AD 用户的数量。 我发现了这个: (Get-ADUser -Filter * -SearchBase “ou=
是否有任何简单的方法可以获取位于给定 OU 下一层的所有 OU 的列表? 即我有一个名为“客户端”的 OU,在这个 OU 下的一个级别有多个 OU,每个客户端一个。即 CAS、ADI、PMA 我想获得
我想使用 C# 将 Active Directory 用户从一个组织单位移动到另一个组织单位。 我已经引用了以下链接 http://forums.asp.net/t/932664.aspx?Movin
我从我们的Exchange服务器获得一个带有标识值的脚本输出: 身份:Domain.com/OU/GivenName姓 如何从值中删除Domain.com/OU/? 正则表达式不是我的优势! :/ 非
我有以下代码: Get-ADUser -SearchBase ‘OU=test,OU=Finance,OU=UserAccounts,DC=FABRIKAM,DC=COM’ -Filter * | F
我有以下代码: Get-ADUser -SearchBase ‘OU=test,OU=Finance,OU=UserAccounts,DC=FABRIKAM,DC=COM’ -Filter * | F
我必须处理的事件目录是这样布置的:域包含许多 OU。这些 OU 之一被命名为“主 OU”。在这个 OU 中,有几个以全局办事处位置命名的 OU(即“芝加哥”“巴黎”)。 任何实际有血有肉的用户帐户都被
刚刚编写了一个脚本来禁用帐户,将其移动到禁用的 OU 并更改用户对象的描述,但我想让它更高效。 我的工作 AD 结构包含根帐户 OU 下的所有用户,以及该帐户 OU 下的 50 个左右的部门 OU。
我正在尝试在用户目录中搜索用户(ou=users,ou=system),但我没有得到结果,请帮助我。以下是我搜索用户目录的代码 public void search(String uid) {
我有一个 Active-Directory 结构,其中用户对象驻留在 OU 中,例如 IT、技术、人力资源、帐户等。我想编写一个 PHP 脚本,使用 AD 对用户进行身份验证,并根据他们的组提供适当的
我必须获取不属于组 OU="Google app User"和 OU=Contacts 的用户的数据,我不知道创建搜索过滤字符串。代码如下--- public SearchResult getUser
使用 PrincipalContext pc = new PrincipalContext(ContextType.Domain, "me.com", "OU=Menetwork OU=Users O
我正在尝试编写一个 PowerShell 脚本,该脚本将查找 AD 中六个月未登录的所有用户,并且不包括 Terminated Users OU 或 Terminated Users\vendors
我需要使用 REGEX 从我的专有名称中提取“OU”部分。 例如: "CN=DAVID Jean Louis (a),OU=Coiffeur,OU=France,DC=Paris,DC=France"
我正在尝试在创建 OU 之前检查它是否存在。我的问题是我有 2 个母 OU“USER BY SITE”和“GROUP BY SITE”,我需要在这 2 个 OU 中拥有完全相同的 OU,1 个用于存储
我正在尝试获取我们整个 OU 受人尊敬的机器上管理员组中所有用户帐户的列表。我找到了一个在单台计算机上显示此内容的脚本,但我想调用计算机名称的 CSV 文件,然后将结果输出到另一个 CSV 文件。这是
function NyChildOU { $overOU = Read-Host "Type in the name of the parrent OU" $oucheck = [adsi]:
这是我的一些示例代码,用于查找 OU 中的所有计算机对象。当我打印出属性字段时,我得到一个 System.__ComObject 用于多个值,例如 lastLogon、lastLogonTimesta
我有一个代码来获取域中的 OU 列表。 现在这只是列出了所有的 OU,并没有给出任何区分 OU 和子 OU 的方法。 DirectoryEntry entry = new DirectoryEntry
我是一名优秀的程序员,十分优秀!