Ejemplo n.º 1
0
        public static List<UserManagerInfo> GetNames(string name)
        {
            List<UserManagerInfo> singleUser = new List<UserManagerInfo>();

            if (name == string.Empty)
            {
                return new List<UserManagerInfo>();
            }

            if (name.Length <= 8)
            {
                UserManagerInfo userManagerInfo = new UserManagerInfo();
                ADUserDetail userDetail;
                userDetail = DirectoryServices.GetUserByLoginName(name);

                if (userDetail != null)
                {
                    if (userDetail.LoginName != null && userDetail.ManagerName != null && userDetail.FirstName != null && userDetail.LastName != null)
                    {
                        userManagerInfo.LoginId = userDetail.LoginName;
                        userManagerInfo.ManagerLoginId = DirectoryServices.GetUserByFullName(userDetail.ManagerName).LoginName;
                        userManagerInfo.ManagerName = userDetail.ManagerName;
                        userManagerInfo.Name = userDetail.FirstName + " " + userDetail.LastName;
                        singleUser.Add(userManagerInfo);
                    }
                }
            }

            if (singleUser.Count == 0) { return DirectoryServices.GetSimplifiedUserManagerInfo(name); }
            else { return singleUser; }
        }
Ejemplo n.º 2
0
 public static UserManagerInfo GetUserManagerInfoByFullName(string fullName)
 {
     var result = new UserManagerInfo();
     var u = GetUserByFullName(fullName);
     if (u != null)
     {
         result = new UserManagerInfo
         {
             LoginId = u.LoginName ?? "unknown",
             ManagerLoginId = u.Manager != null ? u.Manager.LoginName : "unknown",
             ManagerName = u.ManagerName ?? "unknown",
             Name = fullName
         };
     }
     else
     {
         result = new UserManagerInfo
                      {
                          LoginId = "unknown",
                          ManagerLoginId = "unknown",
                          ManagerName = "unknown",
                          Name = "unknown"
                      };
     }
     return result;
 }