ADAM - 有没有办法“存储” 应用程序特定属性?

发布于 2024-07-25 21:54:33 字数 1557 浏览 9 评论 0原文

我有 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);

I have ADAM set-up & I've written web-services to complete admin tasks like adding new users etc. (I have multiple applications utilising the same ADAM instance)

What I am trying to achieve will probably sound a bit odd - but basically I want an admin user to be able to select which attributes the web service should return from ADAM. E.g. application 1 should return displayName & telephoneNumber but application 2 might not need the same attributes returned.

Currently I have set up a SQL Server table to store which attributes the user has selected to be returned & then in the web service looped through this to load the required attributes and add the results to an array to be returned (If your interested I'll add the code at the bottom).

I wanted to know whether there was a better way of doing this? Is it possible to store something like this within ADAM itself?

Thanks in advance for any help!

//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);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文