是否有可能读取使用c#为用户配置文件同步连接配置的所有属性?
本文关键字:配置 连接 属性 同步 配置文件 读取 有可能 用户 是否 | 更新日期: 2023-09-27 18:18:37
是否可以读取为创建用户配置文件同步连接而设置的所有字段?到目前为止,我只能获得连接的显示名称。
请帮助。
提前感谢。
SPServiceContext context = SPServiceContext.GetContext(site);
UserProfileConfigManager upcm = new UserProfileConfigManager(context);
ConnectionManager cm = upcm.ConnectionManager;
foreach (Connection cn in cm)
{
Console.WriteLine("Connection Name " + cn.DisplayName);
}
我想你是指property
而不是fields
使用reflection
是可能的。
foreach (Connection cn in cm)
{
var properties = cn.GetType()
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.Where(i => i.CanRead)
foreach(var property in properties)
{
Console.WriteLine("{0} - {1}", property.Name, property.GetValue(cn));
}
}