c# - 修改后为 AD 注释属性添加值
问题描述
我正在尝试在将值添加到 Active Directory 属性之前对其进行修改注意“Ldap 表示是信息”这个想法是寻找 | 然后做一个返回线示例: USA|France|Algeria 它将是:USA France Algeria
这是我的代码:
//Initialize Notes/info in AD
if (!string.IsNullOrEmpty(attributeNameForInfo))
{
string infoFromPerson = owner.GetAttributeValue(attributeNameForInfo).ToSafeNullableString();
if (!string.IsNullOrEmpty(infoFromPerson))
{
string info = infoFromPerson.Replace("|", "\n");
TdnfTrace.Current.TraceEvent(TraceEventType.Verbose, 112233,
"Custom AD RET : generating info value for " +
owner.Login + " info : " + info);
if (parameters != null && parameters.Keys.Contains("info"))
{
parameters["info"] = info;
}
else if (parameters != null && !parameters.Keys.Contains("info"))
{
parameters.Add("info", info);
}
}
else
TdnfTrace.Current.TraceEvent(TraceEventType.Verbose, 112233,
"Custom AD RET : info value is null for " +owner.Login );
}
但它没有按应有的方式工作。我仍然在 Active Directory 中获取信息,例如 USA FRANCE ALGERIA 它只去掉“|”
我在一些可以使用的论坛上看到Set-ADUser username -Replace @{info='New info for the notes field'}
你能帮忙吗?谢谢
解决方案
所以我通过在“\n”之前添加“\r”解决了我猜的问题
string info = infoFromPerson.Replace("|", "\r\n");
推荐阅读
- doctrine-orm - Vich 上传程序包:映射不存在
- apache-flink - 尽管使用 Apache Flink 进行分区,但元组的分布不平衡
- r - 将行添加到数据框以进行非观察
- stripe-payments - Stripe 客户 A 向客户 B 付款,我们收取费用
- azure-active-directory - 打开 Office 365 插件时,如何避免出现“需要权限/错误请求”对话框?
- python - Matplotlib 擦除图形并绘制新系列子图
- java - Java servlet 获取带有参数的 url
- ruby-on-rails - 在 Rails 上安装捆绑红宝石的问题
- python - 使用 pyspark 中 json 文件中的模式读取固定宽度文件
- android - Google MLKit 能识别同一张脸吗?