我已经设置了 ADAM,并且我已经编写了 Web 服务来完成管理任务,例如添加新用户等。(我有多个应用程序使用同一个 ADAM 实例)
我想要实现的目标可能听起来有点奇怪——但基本上我希望管理员用户能够选择 Web 服务应该从 ADAM 返回的属性。例如,应用程序 1 应该返回 displayName 和电话号码,但应用程序 2 可能不需要返回相同的属性。
目前,我已经设置了一个 SQL Server 表来存储用户选择返回的属性,然后在 Web 服务中循环通过它来加载所需的属性并将结果添加到要返回的数组中(如果你感兴趣,我将在底部添加代码)。
我想知道是否有更好的方法来做到这一点?是否可以在 ADAM 本身中存储这样的内容?
提前感谢您的帮助!
//using linq to access table
DataClasses1DataContext db = new DataClasses1DataContext();
var queryAttributes = from atr in db.AttributesToReturns
where atr.appNumber == appNumber
select atr;
ArrayList userD = new ArrayList();
foreach (var a in queryAttributes)
{
//the col 'attribute' contains the exact name in active direct e.g. displayName
string att = a.attribute.ToString();
searcher.PropertiesToLoad.Add(att);
}
//--code omitted but here perform search & get req Directory Entry
foreach (var a in queryAttributes)
{
string attributeName = a.attribute.ToString();
try
{
string value = user.Properties[attributeName].Value.ToString();
//do something with value - here i am updating a user object which will be added to the ArrayList the webservice is returning
updateUser(u, attributeName, value);
}
//if an error - just set value to empty
catch (Exception ex)
{
string value = "NULL";
updateUser(u, attributeName, value);
}
}
userD.Add(u);