是否可以使用 c# 读取为用户配置文件同步连接配置的所有属性
Is it possible to read all properties configured for a user profile sync connection using c#
是否可以读取为创建用户配置文件同步连接而设置的所有字段。
到目前为止,我只能获得连接的显示名称。
请帮忙。
提前致谢。
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));
}
}
是否可以读取为创建用户配置文件同步连接而设置的所有字段。 到目前为止,我只能获得连接的显示名称。
请帮忙。
提前致谢。
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));
}
}