Exemple #1
0
 public void OUEntrySyncRtx(DirectoryEntry entry, string filter, RtxDeptManager dept)
 {
     using (DirectorySearcher objSearcher = new DirectorySearcher(entry, filter))
     {
         objSearcher.PropertiesToLoad.Add("distinguishedName");
         SearchResultCollection srcs = objSearcher.FindAll();
         foreach (SearchResult src in srcs)
         {
             string[] strs = src.Properties["distinguishedName"][0].ToString().Split(',');
             if (!strs[1].Contains("OU="))
             {
                 dept.AddDept(strs[0].Replace("OU=", ""), "");
             }
             else
             {
                 dept.RemoveDept(strs[0].Replace("OU=", ""));
                 dept.AddDept(strs[0].Replace("OU=", ""), strs[1].Replace("OU=", ""));
             }
         }
     }
 }
Exemple #2
0
 public bool AddUserBasic(DomainUser user, string path, int IAuthType)
 {
     try
     {
         UserManager.AddUser(user.Name, IAuthType);
         string userName    = user.Name;
         string displayName = "RTX_NULL";
         int    gender      = -1;
         string mobile      = "RTX_NULL";
         string email       = "RTX_NULL";
         string phone       = "RTX_NULL";
         if (string.IsNullOrEmpty(user.DisplayName))
         {
             displayName = user.DisplayName;
         }
         if (string.IsNullOrEmpty(user.Mail))
         {
             email = user.Mail;
         }
         if (string.IsNullOrEmpty(user.TelephoneNumber))
         {
             mobile = user.TelephoneNumber;
             phone  = mobile;
         }
         if (string.IsNullOrEmpty(user.Initials))
         {
             gender = Convert.ToInt32(user.Initials);
         }
         UserManager.SetUserBasicInfo(userName, displayName, gender, mobile, email, phone, IAuthType);
         RtxDeptManager rdm = new RtxDeptManager();
         rdm.AddUserToDept(userName, null, path, false);
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Exemple #3
0
 public void UserEntrySyncRtx(DirectoryEntry entry, string filter, RtxUserManager user, RtxDeptManager dept)
 {
     using (DirectorySearcher objSearcher = new DirectorySearcher(entry, filter))
     {
         objSearcher.PropertiesToLoad.Add("distinguishedName");
         objSearcher.PropertiesToLoad.Add("name");
         objSearcher.PropertiesToLoad.Add("displayName");
         objSearcher.PropertiesToLoad.Add("mail");
         objSearcher.PropertiesToLoad.Add("telephoneNumber");
         objSearcher.PropertiesToLoad.Add("initials");
         SearchResultCollection srcs = objSearcher.FindAll();
         foreach (SearchResult src in srcs)
         {
             string[]      paths    = src.Properties["distinguishedName"][0].ToString().Replace("DC=", "").Replace("OU=", "").Replace("CN=", "").Split(',');
             string        deptName = paths[1];
             StringBuilder builder  = new StringBuilder();
             for (int i = paths.Length - 1; i > 0; i--)
             {
                 builder.Append(paths[i]).Append(@"\");
             }
             string path        = builder.ToString().Replace(@"com\test\", "");
             string userName    = src.Properties["name"][0].ToString();
             string displayName = "RTX_NULL";
             int    gender      = -1;
             string mobile      = "RTX_NULL";
             string email       = "RTX_NULL";
             string phone       = "RTX_NULL";
             if (src.Properties["displayName"].Count == 1)
             {
                 displayName = src.Properties["displayName"][0].ToString();
             }
             if (src.Properties["mail"].Count == 1)
             {
                 email = src.Properties["mail"][0].ToString();
             }
             if (src.Properties["telephoneNumber"].Count == 1)
             {
                 mobile = src.Properties["telephoneNumber"][0].ToString();
                 phone  = mobile;
             }
             if (src.Properties["initials"].Count == 1)
             {
                 gender = Convert.ToInt32(src.Properties["initials"][0]);
             }
             if (user.IsUserExist(userName))
             {
                 user.SetBasicRtxUser(userName, displayName, gender, phone, email, phone, 1);
                 dept.AddUserToDept(userName, dept.GetUserDeptsName(userName), path, false);
             }
             else
             {
                 user.AddRtxUser(userName, 1);
                 user.SetBasicRtxUser(userName, displayName, gender, mobile, email, phone, 1);
                 dept.AddUserToDept(userName, null, path, false);
             }
         }
     }
 }