修改后为 ADD note 属性添加值
Add a value to AD note attribute after modifciation
我试图在将值添加到 Active Directory 属性之前修改值注意“Ldap 表示是信息”
这个想法是寻找|然后做一个 return 行示例: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");
我试图在将值添加到 Active Directory 属性之前修改值注意“Ldap 表示是信息” 这个想法是寻找|然后做一个 return 行示例: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");