zoukankan      html  css  js  c++  java
  • 在MOSS2010中实现OU下的用户的上下级组织关系

    在MOSS2010中实现OU下的用户的上下级组织关系

     

    MOSS2010中实现OU下的用户的上下级组织关系

    前言

    大家都知道无论是AD还是MOSS,目前都没有实现用户的上下级组织结构关系。AD的用户都是平级的展示。前不久刚好接触一个项目,客户要求实现用户的上下级组织结构关系,如下图:

    clip_image002

    于是开始动手设计和开发,经过一番的努力思考和测试,发现在MOSS2010的UserProfile带有很多属性,也支持扩展属性。发现自带有【经理】的属性。亮点就在这里,把【经理】属性开放到每个人的个人配置信息中去,让用户自己编辑设置自己的上级经理(注:不一定用此类属性,也可以在扩展一个属性,如:用级别区别等)。如下图:

    clip_image004

    clip_image005

    默认【经理】属性值为空的就是这个OU下的最高领导。以下的依次编辑的自己的经理

    提示:这里有个小问题。就是如果每个人都没有编辑设置自己的经理。那么就没有组织关系的产生或有些设置了,有人没设置,那么关系就乱了。当然我们也知道技术只能减轻人的工作量但是代替不了人的工作,所以我们需要靠管理制度去约束。让每个人按照实际规定去设置信息(或采用代码去批量设置)

    鉴于上面的思路,设计思路就有了,开发起来就简单多了。左边是AD的OU,右边点击OU展示对应的上下级关系。效果图如下:

    clip_image007

    实现

    左边AD的OU树代码网上很多,我这里不罗嗦了。我重点说说右边的用户属性如何读取?

    大家都知道MOSS2010的userProfile提供了接口的。接口方法如下:

    方法1:

    /// <summary>

    /// 获取用户属性

    /// </summary>

    /// <param name="accountName">登录账号</param>

    /// <returns></returns>

    public static UserProfile GetUserInfo(string AccountName)

    {

    UserProfile profile = null;

    string strUrl = "http://win-moss:8010";

    SPSite site = new SPSite(strUrl);

    try

    {

    SPServiceContext serviceContext = SPServiceContext.GetContext(site);

    //SPServiceContext serviceContext = SPServiceContext.Current;

    UserProfileManager profileManager = new UserProfileManager(serviceContext);

    if (AccountName != string.Empty)

    {

    profile = profileManager.GetUserProfile(AccountName);

    }

    else

    {

    profile = profileManager.GetUserProfile(SPContext.Current.Web.CurrentUser.RawSid);

    }

    }

    finally

    {

    site.Dispose();

    }

    return profile;

    }

    调用,如读取经理属性:

    // PropertyConstants很多属性,自己可以看出

    userfile[PropertyConstants.Manager].Value

    方法2:

    /// <summary>

    /// 获取用户属性

    /// </summary>

    /// <param name="accountName">登录账号</param>

    /// <param name="propertyDisplayName">属性显示名称</param>

    /// <returns></returns>

    public static object GetUserProperty(string accountName, string propertyDisplayName)

    {

    object userPropertyValue = null;

    UserProfile userProfile = GetUserInfo(accountName);//调用的1方法中的

    if (userProfile != null)

    {

    var profileSubtypeProperty = userProfile.Properties.First(propertyBase => propertyBase.DisplayName == propertyDisplayName);

    if (profileSubtypeProperty != null)

    {

    userPropertyValue = userProfile.GetProfileValueCollection(profileSubtypeProperty.Name).Value;

    }

    }

    return userPropertyValue;

    }

    调用,如读取经理属性:

    GetUserProperty("contoso\Liwang", "经理")

    经过编码后最后效果图如下:

    clip_image009

    经过效果改进:

    集成lync状态如下图:

    查看详细信息如下图:

  • 相关阅读:
    python35 1.守护进程 2.互斥锁3.IPC 4.生产者和消费者模型
    python34 多进程: 1.进程与程序的区别 2.阻塞 非阻塞 并行 并发(重点) 3.进程三种方式的切换 4.程序员永恒的话题 5.进程的创建以及销毁 6.进程的两种使用方式(重点) 7.join函数(重点) 8.process常用属性 9僵尸与孤儿进程(了解)
    Python33 1.UDP协议 2.与TCP区别 3.DNS服务器 4.进程----进入并发编程的学习 5.操作系统 6.多道技术
    Mybatis 属性配置
    SqlSessionFactoryBuilder、SqlSessionFactory、SqlSession
    MyBatis 简单入门
    spring mvc 异步 DeferredResult
    Spring MVC 异步请求 Callable
    Servlet 异步处理
    @EnableWebMvc
  • 原文地址:https://www.cnblogs.com/ningang/p/4321631.html
Copyright © 2011-2022 走看看