Beispiel #1
0
 public void AddMember(LcpsAdsUser u)
 {
     try
     {
         DirectoryEntry.Properties["member"].Add(u.DistinguishedName);
         DirectoryEntry.CommitChanges();
         DirectoryEntry.RefreshCache();
     }
     catch(Exception ex)
     {
         throw new Exception(string.Format("Error adding {0} to {1}", u.UserName, Name), ex);
     }
 }
Beispiel #2
0
        public static LcpsAdsUser[] GetUsers(string filter, DirectoryEntry lookIn, bool recursive)
        {
            List<LcpsAdsUser> l = new List<LcpsAdsUser>();

            using (DirectorySearcher s = new DirectorySearcher(lookIn, filter))
            {
                if (recursive)
                    s.SearchScope = SearchScope.Subtree;
                else
                    s.SearchScope = SearchScope.OneLevel;

                foreach (SearchResult r in s.FindAll())
                {
                    DirectoryEntry e = r.GetDirectoryEntry();
                    LcpsAdsUser u = new LcpsAdsUser(e);
                    l.Add(u);
                }
            }

            return l.ToArray();
        }
Beispiel #3
0
 public static LcpsAdsUser Get(string userName)
 {
     string filter = string.Format("(&(samAccountName={0}))", userName);
     DirectoryEntry d = Find(filter, LcpsAdsDomain.Default.DirectoryEntry);
     LcpsAdsUser u = new LcpsAdsUser(d);
     return u;
 }