Esempio n. 1
0
        /// <summary>
        /// Given an poBox object , it will return the rule for a PolicyID
        /// only one rule is returned
        /// </summary>
        public void GetRuleForPolicyID(POBox.POBox poBox, string PolicyID, ref Member member)
        {
            string RuleList = "RuleList";

            Simias.Policy.Rule rule = null;
            ICSList            list = poBox.Search(PropertyTags.PolicyID, PolicyID, SearchOp.Equal);

            foreach (ShallowNode sn in list)
            {
                Simias.Policy.Policy tempPolicy = new Simias.Policy.Policy(poBox, sn);
                if (tempPolicy.IsSystemPolicy)
                {
                    MultiValuedList mvl = tempPolicy.Properties.GetProperties(RuleList);
                    if (mvl.Count > 0)
                    {
                        foreach (Property p in mvl)
                        {
                            if (p != null)
                            {
                                rule = new Simias.Policy.Rule(p.Value);
                                Property prop = new Property(PolicyID, rule.ToString());
                                prop.ServerOnlyProperty = true;
                                member.Properties.ModifyProperty(prop);
                                break;
                            }
                        }
                    }
                }
            }
            return;
        }
Esempio n. 2
0
        /// <summary>
        /// Start the PO Box manager.
        /// </summary>
        public void Start()
        {
            try
            {
                lock (this)
                {
                    log.Debug("Starting PO Service: {0}", ServiceUrl);

                    // Get a list of all POBoxes.
                    ICSList poBoxList = store.GetCollectionsByType(NodeTypes.POBoxType);
                    foreach (ShallowNode sn in poBoxList)
                    {
                        // Get the domain for this POBox.
                        POBox poBox = new POBox(store, sn);
                        Simias.Storage.Domain domain = store.GetDomain(poBox.Domain);
                        //if (domain.Role == SyncRoles.Slave)
                        //{
                        // start collection managers
                        AddPOBoxManager(poBox.ID);
                        //}
                    }
                }
            }
            catch (Exception e)
            {
                log.Error(e, "Unable to start PO manager.");

                throw e;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Removes all subscriptions for the collection that is contained in the event.
        /// </summary>
        /// <param name="args">Node event arguments.</param>
        private void OnCollectionNoAccess(NodeEventArgs args)
        {
            // Make sure that this is an event for a collection.
            if (args.Collection == args.ID)
            {
                // Search the POBox collections for a subscription for this collection.
                Property p = new Property(Subscription.SubscriptionCollectionIDProperty, args.ID);

                // Find all of the subscriptions for this POBox.
                ICSList list = store.GetNodesByProperty(p, SearchOp.Equal);
                foreach (ShallowNode sn in list)
                {
                    // Make sure that this node is a subscription.
                    if (sn.Type == NodeTypes.SubscriptionType)
                    {
                        // Get the collection (POBox) for this subscription.
                        POBox poBox = POBox.GetPOBoxByID(store, sn.CollectionID);
                        if (poBox != null)
                        {
                            // Delete this subscription from the POBox.
                            poBox.Commit(poBox.Delete(new Subscription(poBox, sn)));
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// This API will clean all certificate (.?er files)
        /// before Server, store existing and new certificate and load them in Hash table.
        /// </summary>
        public static void CleanCertsFromStore()
        {
            Store   store         = Store.GetStore();
            ICSList domainList    = store.GetDomainList();
            Boolean isLocalDomain = false;

            foreach (ShallowNode snd in domainList)
            {
                Domain  domain = store.GetDomain(snd.ID);
                ICSList certs  = domain.GetNodesByType(CertType);
                isLocalDomain = domain.Name.Equals(Store.LocalDomainName);
                foreach (ShallowNode sn in certs)
                {
                    Node node = new Node(domain, sn);
                    try
                    {
                        string nodeProperty = node.Properties.GetSingleProperty(isLocalDomain?hostProperty:raProperty).Value.ToString();
                        if (nodeProperty != null)
                        {
                            log.Debug("Node deleted is:{0}", node.Name);
                            domain.Commit(domain.Delete(node));
                        }
                    }
                    catch
                    {
                        log.Error("Exception while clearing existing Certificates from Domain");
                    }
                } //End of Inner foreach loop
            }     // End of Outer foreach loop
        }         //End of Function
Esempio n. 5
0
        /// <summary>
        /// Start the PO service.
        /// </summary>
        public void Start()
        {
#if (!REMOVE_OLD_INVITATION)
            lock (typeof(POService))
            {
                if (subscriptionService == null)
                {
                    // Start the subscription thread.
                    subscriptionService = new SubscriptionService();
                }
            }
#endif
            // Get a list of all POBoxes.
            ICSList poBoxList = store.GetCollectionsByType(NodeTypes.POBoxType);
            foreach (ShallowNode sn in poBoxList)
            {
                // Add the existing POBoxes to the mapping table.
                POBox poBox = new POBox(store, sn);
                poBoxTable[poBox.ID] = poBox.Domain;

#if (!REMOVE_OLD_INVITATION)
                // Process any active subscriptions.
                ProcessWaitingSubscriptions(poBox);
#endif
            }

            poBoxSubscriber.Enabled      = true;
            invitationSubscriber.Enabled = true;
#if (!REMOVE_OLD_INVITATION)
            noAccessSubscriber.Enabled = true;
#endif
        }
Esempio n. 6
0
        /// <summary>
        /// Remove the certificate for the specified host.
        /// </summary>
        /// <param name="host">The host the certificate belongs to.</param>
        public static void RemoveCertificate(string host)
        {
            string uriHost = GetHostFromUri(host);

            log.Debug("removing for host : {0}", uriHost);
            CertPolicy.RemoveCertificate(uriHost);
            log.Debug("removed for host : {0}", uriHost);

            // also remove it from store , if any
            Store  store  = Store.GetStore();
            Domain domain = store.GetDomain(store.LocalDomain);

            // Check for an existing cert in the store.
            Node    cn       = null;
            ICSList nodeList = domain.Search(hostProperty, uriHost, SearchOp.Equal);

            foreach (ShallowNode sn in nodeList)
            {
                cn = new Node(domain, sn);
                if (cn.IsType(CertType))
                {
                    Property myprop = cn.Properties.GetSingleProperty(certificateProperty);
                    if (myprop != null)
                    {
                        domain.Commit(domain.Delete(cn));
                        log.Debug("committed the deletion of certtype node for :{0} ", uriHost);
                    }
                }
            }
        }
Esempio n. 7
0
        // We call catalog services to read the entries.. Not using discovery because no need...Only read operation is performed
        /// <summary>
        /// Collective space used by group member.
        /// </summary>
        /// <param name="groupID">Group id whose members space need to be calculated.</param>
        /// <returns></returns>
        static public long GetSpaceUsedByAllGroupMembers(string groupID)
        {
            long       SpaceUsed     = 0;
            string     catalogID     = "a93266fd-55de-4590-b1c7-428f2fed815d";
            string     OwnerProperty = "oid";
            string     SizeProperty  = "size";
            Collection catalog;
            //ArrayList entries = new ArrayList();
            Store  store  = Store.GetStore();
            Domain domain = store.GetDomain(store.DefaultDomain);

            string [] GroupMembers = domain.GetGroupsMemberList(groupID);

            catalog = store.GetCollectionByID(catalogID);

            foreach (string memberID in GroupMembers)
            {
                Property midsProp = new Property(OwnerProperty, memberID);
                ICSList  nodes    = catalog.Search(midsProp, SearchOp.Equal);
                foreach (ShallowNode sn in nodes)
                {
                    Node     node = new Node(catalog, sn);
                    Property p    = node.Properties.GetSingleProperty(SizeProperty);
                    SpaceUsed += (p != null) ? ( long )p.Value : 0;;
                }
            }

            return(SpaceUsed);
        }
Esempio n. 8
0
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="hNode">HostNode object</param>
        internal HostEntry(HostNode hNode)
        {
            host = hNode;
            ICSList members = hNode.GetHostedMembers();

            userCount = members.Count;
        }
Esempio n. 9
0
        /// <summary>
        /// Given an poBox object , it will return the value for a PolicyID , and PolicyTag .
        /// Only one value is returned
        /// </summary>
        public int GetValueForPolicyID(POBox.POBox poBox, string PolicyID, string PolicyTag)
        {
            int     PolicyValue = -1;
            ICSList list        = poBox.Search(PropertyTags.PolicyID, PolicyID, SearchOp.Equal);

            foreach (ShallowNode sn in list)
            {
                Simias.Policy.Policy tempPolicy = new Simias.Policy.Policy(poBox, sn);
                if (tempPolicy.IsSystemPolicy)
                {
                    MultiValuedList mvl = tempPolicy.Properties.GetProperties(PolicyTag);
                    if (mvl.Count > 0)
                    {
                        foreach (Property p in mvl)
                        {
                            if (p != null)
                            {
                                PolicyValue = (int)p.Value;
                                break;
                            }
                        }
                    }
                }
            }
            return(PolicyValue);
        }
Esempio n. 10
0
        /// <summary>
        /// Utility method to delete a member's POBox from the system
        /// </summary>
        public static bool DeletePOBox(string DomainID, string UserID)
        {
            bool deleted = false;

            try
            {
                Store   store = Store.GetStore();
                ICSList cList = store.GetCollectionsByOwner(UserID);
                foreach (ShallowNode sn in cList)
                {
                    Collection c = new Collection(store, sn);
                    if ((c.Domain == DomainID) &&
                        ((Node)c).IsBaseType(NodeTypes.POBoxType))
                    {
                        c.Commit(c.Delete());
                        deleted = true;
                        break;
                    }
                }
            }
            catch (Exception e2)
            {
                log.Error(e2.Message);
                log.Error(e2.StackTrace);
            }

            return(deleted);
        }
Esempio n. 11
0
        public BrowserShallowNode[] SearchForShallowNodes(string collectionID, string propertyName, string propertyType, string propertyValue, string operation)
        {
            ArrayList list  = new ArrayList();
            Store     store = Store.GetStore();

            // Build the property to search for.
            Property p = new Property(propertyName, ( Syntax )Enum.Parse(typeof(Syntax), propertyType), propertyValue);

            if (collectionID == null || collectionID.Equals(string.Empty))
            {
                // The collection ID was not specified ... perform a store-wide search.
                ICSList nodeList = store.GetNodesByProperty(p, ( SearchOp )Enum.Parse(typeof(SearchOp), operation));
                foreach (ShallowNode sn in nodeList)
                {
                    list.Add(new BrowserShallowNode(sn));
                }
            }
            else
            {
                // Get the collection.
                Collection c = store.GetCollectionByID(collectionID);
                if (c != null)
                {
                    // Search the collection.
                    ICSList nodeList = c.Search(p, ( SearchOp )Enum.Parse(typeof(SearchOp), operation));
                    foreach (ShallowNode sn in nodeList)
                    {
                        list.Add(new BrowserShallowNode(sn));
                    }
                }
            }

            return(list.ToArray(typeof(BrowserShallowNode)) as BrowserShallowNode[]);
        }
Esempio n. 12
0
        /// <summary>
        /// Gets the distinguished name from the member name.
        /// </summary>
        /// <param name="user">The user name.</param>
        /// <param name="distinguishedName">Receives the ldap distinguished name.</param>
        /// <param name="id">Receives the member's user ID.</param>
        /// <returns>True if the distinguished name was found.</returns>
        private bool GetUserDN(string user, out string distinguishedName, out string id)
        {
            bool   status = false;
            Member member = null;

            // Initialize the outputs.
            distinguishedName = String.Empty;
            id = String.Empty;

            if (domain != null)
            {
                member = domain.GetMemberByName(user);
                if (member != null)
                {
                    Property dn = member.Properties.GetSingleProperty("DN");
                    if (dn != null)
                    {
                        distinguishedName = dn.ToString();
                        id     = member.UserID;
                        status = true;
                    }
                }
                else
                {
                    // The specified user did not exist in the roster under
                    // the short or common name.
                    // Let's see if the user came in fully distinguished.
                    // ex. cn=user.o=context

                    string dn = user.ToLower();
                    if (dn.StartsWith("cn=") == true)
                    {
                        // NDAP name to LDAP name
                        dn = dn.Replace('.', ',');
                        ICSList dnList = domain.Search("DN", dn, SearchOp.Equal);
                        if (dnList != null && dnList.Count == 1)
                        {
                            IEnumerator dnEnum = dnList.GetEnumerator();
                            if (dnEnum.MoveNext() == true)
                            {
                                member = new Member(domain, dnEnum.Current as ShallowNode);
                                if (member != null)
                                {
                                    distinguishedName = dn;
                                    id     = member.UserID;
                                    status = true;
                                }
                            }
                        }
                    }
                }
            }

            return(status);
        }
Esempio n. 13
0
        /// <summary>
        /// Locates a Subscription in the POBox by CollectionID
        /// </summary>
        /// <param name="collectionID">The ID of the collection.</param>
        /// <returns>A Subscription object.</returns>
        public Subscription GetSubscriptionByCollectionID(string collectionID)
        {
            ICSList subList = this.Search(
                Subscription.SubscriptionCollectionIDProperty,
                collectionID,
                SearchOp.Equal);

            foreach (ShallowNode sNode in subList)
            {
                return(new Subscription(this, sNode));
            }
            return(null);
        }
Esempio n. 14
0
    public static void GetCollisionNodes( )
    {
        Store.Initialize(SimiasDataPath, true, -1);
        Store store = Store.GetStore();

        if (store == null)
        {
            Console.WriteLine("store could not be initialized.....");
        }
        Domain domain = store.GetDomain(store.DefaultDomain);

        SearchOp searchOperation = SearchOp.Begins;
        string   pattern         = "*";
        int      max             = 0;
        int      index           = 0;

        Console.WriteLine();
        Console.WriteLine("**************************Collision Nodes Report********************* ");
        Console.WriteLine();

        Simias.Storage.SearchPropertyList SearchPrpList = new Simias.Storage.SearchPropertyList();
        int i = 0;

        SearchPrpList.Add(CollisionProperty, "*", SearchOp.Exists);
        SearchPrpList.Add(BaseSchema.ObjectName, pattern, searchOperation);
        try{
            ICSList searchList = Catalog.Search(SearchPrpList);

            SearchState searchState = new SearchState(domain.ID, searchList.GetEnumerator() as ICSEnumerator, searchList.Count);
            if (index != 0)
            {
                searchState.Enumerator.SetCursor(Simias.Storage.Provider.IndexOrigin.SET, index);
            }
            foreach (ShallowNode sn in searchList)
            {
                if (max != 0 && i++ >= max)
                {
                    break;
                }
                CatalogEntry catEntry = Catalog.ConvertToCataloEntry(sn);
                Console.WriteLine("iFolder Name :{0}, iFolder ID:{1}", catEntry.Name, catEntry.CollectionID);
            }
        }
        catch (Exception ee)
        {
            Console.WriteLine("Got exception: " + ee.Message);
        }
        finally{
            Store.DeleteInstance();
        }
    }
Esempio n. 15
0
        /// <summary>
        /// Returns the total amount of disk space used by this member.
        /// </summary>
        /// <param name="member">Member to find used disk space for.</param>
        /// <returns>Amount of used disk space in bytes.</returns>
        private long GetUsedDiskSpace(Member member)
        {
            long collectionSpace = 0;

            // Get all of the collections that are owned by the member.
            Store   store          = Store.GetStore();
            ICSList collectionList = store.GetCollectionsByOwner(member.UserID, member.GetDomainID(store));

            foreach (ShallowNode sn in collectionList)
            {
                Collection c = new Collection(store, sn);
                collectionSpace += c.StorageSize;
            }

            return(collectionSpace);
        }
Esempio n. 16
0
        /// <summary>
        /// Store the certificate for the specified host.
        /// </summary>
        /// <param name="certificate">The certificate to store.</param>
        /// <param name="host">The host the certificate belongs to.</param>
        /// <param name="domainID">the domainID to which host belongs</param>
        /// <param name="persist">If true save in store.</param>
        public static void StoreDomainCertificate(byte[] certificate, string host, string domainID, bool persist)
        {
            // this function is neither tested nor used
            string uriHost = GetHostFromUri(host);

            log.Debug("storing certificate for host : {0}", uriHost);
            CertPolicy.StoreCertificate(certificate, uriHost);
            //try
            //{
            if (persist)
            {
                // Save the cert in the store.
                Store  store  = Store.GetStore();
                Domain domain = store.GetDomain(domainID);

                // Check for an existing cert in the store.
                Node    cn       = null;
                ICSList nodeList = domain.Search(hostProperty, uriHost, SearchOp.Equal);
                foreach (ShallowNode sn in nodeList)
                {
                    cn = new Node(domain, sn);
                    if (!cn.IsType(CertType))
                    {
                        cn = null;
                        continue;
                    }
                    break;
                }

                if (cn == null)
                {
                    // The cert doesn't exist ... create it.
                    //cn=new Node("
                    cn = new Node("Certificate for " + uriHost);
                    domain.SetType(cn, CertType);
                    cn.Properties.ModifyNodeProperty(new Property(hostProperty, uriHost));
                }
                Property myprop = new Property(certificateProperty, Convert.ToBase64String(certificate));
                myprop.LocalProperty = true;
                cn.Properties.ModifyNodeProperty(myprop);
                //cn.Properties.ModifyNodeProperty(new Property(certificateProperty, Convert.ToBase64String(certificate)));
                log.Debug("committed the storage of certificate");
                domain.Commit(cn);
            }
            //}catch(Exception ex){}
        }
Esempio n. 17
0
        /// <summary>
        /// Locates a Subscription in the POBox by CollectionID and UserID.
        /// </summary>
        /// <param name="collectionID">The ID of the collection.</param>
        /// <param name="userID">The ID of the user to whom the subscription is addressed.</param>
        /// <returns>A Subscription object.</returns>
        public Subscription GetSubscriptionByCollectionID(string collectionID, string userID)
        {
            ICSList subList = this.Search(
                Subscription.SubscriptionCollectionIDProperty,
                collectionID,
                SearchOp.Equal);

            foreach (ShallowNode sn in subList)
            {
                Subscription sub = new Subscription(this, sn);
                if (sub.ToIdentity.Equals(userID))
                {
                    return(sub);
                }
            }

            return(null);
        }
Esempio n. 18
0
        /// <summary>
        /// Creates a file size filter policy for the specified member.
        /// </summary>
        /// <param name="member">Member that the filter will be associated with.</param>
        /// <param name="limit">Size of file in bytes that all users in the domain will be limited to.</param>
        static public void Create(Member member, long limit)
        {
            ICSList ftList = new ICSList();

            // Need a policy manager.
            PolicyManager pm = new PolicyManager();

            if (limit > 0)
            {
                ftList.Add(new Rule(limit, Rule.Operation.Greater, Rule.Result.Deny));

                pm.CommitPolicy(FileSizeFilterPolicyID, ftList, member);
            }
            else
            {
                pm.DeletePolicy(FileSizeFilterPolicyID, member);
            }
        }
Esempio n. 19
0
    public static void GetReports( )
    {
        //if( replace == false ) Console.WriteLine("You have opted to view and not delete..Use enable to modify also "); else Console.WriteLine("It will modify the members");
        Store.Initialize(SimiasDataPath, true, -1);
        Store store = Store.GetStore();

        if (store == null)
        {
            Console.WriteLine("store could not be initialized.....");
        }
        Domain domain = store.GetDomain(store.DefaultDomain);

        Console.WriteLine("**************************IFOLDER REPORT********************* ");
        Console.WriteLine();
        Console.WriteLine();
        try
        {
            ICSList ifolders = store.GetCollectionsByType("iFolder");
            foreach (ShallowNode sn in ifolders)
            {
                object[] cells = new object[count];

                Collection ifolder = store.GetCollectionByID(sn.ID);
                Member     owner   = domain.GetMemberByID(ifolder.Owner.UserID);

                Console.WriteLine("                          *************");
                Console.WriteLine("user name is :{0} and iFolder name is :{1}", owner.FN, ifolder.Name);
                Console.WriteLine("iFolder quota is :{0}", DiskSpaceQuota.GetLimit(ifolder));
                Console.WriteLine("Users quota is :{0}", DiskSpaceQuota.Get(owner).Limit);
                Console.WriteLine("                         ");
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine(ex);
            Console.WriteLine(ex.StackTrace);
        }
        finally
        {
            Store.DeleteInstance();
        }
    }
Esempio n. 20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rsa"></param>
        /// <param name="recoveryAgnt"></param>
        /// <param name="persist"></param>
        public static void CheckAndStoreRSA(string rsa, string recoveryAgnt, bool persist)
        {
            bool   toStore  = true;
            int    count    = 0;
            Store  store    = Store.GetStore();
            string domainID = store.DefaultDomain;

            if (domainID != null)
            {
                Domain  domain = store.GetDomain(store.DefaultDomain);
                ICSList rsas   = domain.GetNodesByType(RSAType);

                foreach (ShallowNode sn in rsas)
                {
                    Node node = new Node(domain, sn);
                    try
                    {
                        if (count++ > 0)
                        {
                            throw new Exception("Too many Default RSA");
                        }
                        string nodeProperty = node.Properties.GetSingleProperty(raProperty).Value.ToString();
                        if (nodeProperty != null)
                        {
                            toStore = false;
                        }
                        else
                        {
                            toStore = true;
                        }
                    }
                    catch (Exception e)
                    {
                        log.Fatal("RSA Check Error: {0}", e.Message);
                        return;
                    }
                }

                if (toStore)
                {
                    StoreRARSA(rsa, recoveryAgnt, persist);
                }
            }
        }
Esempio n. 21
0
    public static ArrayList getAllDomainUsers(Domain domain, string username)
    {
        SearchProperty  searchProperty  = SearchProperty.UserName;
        SearchOperation searchOperation = SearchOperation.BeginsWith;
        string          pattern         = "*";

        Simias.Storage.SearchPropertyList SearchPrpList = new Simias.Storage.SearchPropertyList();
        //SearchPrpList.Add(searchProperty, pattern, searchOperation);
        SearchPrpList.Add("DN", "*", SearchOp.Exists);
        ICSList   searchList = domain.Search(SearchPrpList);
        ArrayList list       = new ArrayList();
        Member    member     = null;

        Console.WriteLine("Total No Of Users in Domain: " + searchList.Count);
        foreach (ShallowNode sn in searchList)
        {
            try
            {
                if (sn.IsBaseType(NodeTypes.MemberType))
                {
                    member = new Member(domain, sn);
                    Member mem = domain.GetMemberByID(member.UserID);
                    //add only those members to list whose home server is current server
                    if (mem.HomeServer != null)
                    {
                        if (String.Equals(mem.Name, username) && mem.HomeServer.UserID == HostNode.GetLocalHost().UserID)
                        {
                            list.Add(mem);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                Console.WriteLine("Error Trace: " + ex.StackTrace);
            }
        }
        Console.WriteLine("Total No Of Users for whom Home Server is current server: " + list.Count);
        return(list);
    }
Esempio n. 22
0
        /// <summary>
        /// Get an iFolder Entry By Relative Path
        /// </summary>
        /// <param name="c"></param>
        /// <param name="entryPath"></param>
        /// <returns></returns>
        internal static Node GetEntryByPath(Collection c, string entryPath)
        {
            Node n = null;

            entryPath = entryPath.Trim(new char[] { '/' });

            ICSList children = c.Search(PropertyTags.FileSystemPath, entryPath, SearchOp.Equal);

            foreach (ShallowNode sn in children)
            {
                Node child = c.GetNodeByID(sn.ID);

                if (child.IsBaseType(NodeTypes.FileNodeType) || child.IsBaseType(NodeTypes.DirNodeType))
                {
                    n = child;
                    break;
                }
            }

            return(n);
        }
Esempio n. 23
0
        /// <summary>
        /// Removes the subscription for this collection from the specified member.
        /// </summary>
        /// <param name="member">Member to remove subscription from.</param>
        public static void RemoveSubscriptionByMember(string domainID, string collectionID, string userID)
        {
            Store store = Store.GetStore();

#if (!REMOVE_OLD_INVITATION)
            Domain domain = store.GetDomain(domainID);
            if ((domain != null) && (domain.SupportsNewInvitation == true))
            {
#endif
            // Get the member's POBox.
            POBox poBox = POBox.FindPOBox(store, domainID, userID);
            if (poBox != null)
            {
                ICSList subList = poBox.Search(Subscription.SubscriptionCollectionIDProperty, collectionID, SearchOp.Equal);
                if (subList.Count > 0)
                {
                    foreach (ShallowNode sn in subList)
                    {
                        // No need to process further invitation events. The collection cannot be deleted
                        // by removing its members, because the owner of the collection can never be deleted.
                        Subscription subscription = new Subscription(poBox, sn);
                        subscription.CascadeEvents = false;
                        poBox.Commit(poBox.Delete(subscription));
                        log.Debug("RemoveSubscriptionByMember - Removed subscription {0} from member {1}.", sn.ID, userID);
                    }
                }
                else
                {
                    log.Debug("RemoveSubscriptionByMember - No subscriptions found for member {0}.", userID);
                }
            }
            else
            {
                log.Debug("RemoveSubscriptionByMember - Cannot find POBox for member {0}.", userID);
            }
#if (!REMOVE_OLD_INVITATION)
        }
#endif
        }
Esempio n. 24
0
        /// <summary>
        /// Removes all subscriptions associated with this collection.
        /// </summary>
        /// <param name="domainID"></param>
        /// <param name="collectionID"></param>
        /// <param name="userID"></param>
        public static void RemoveSubscriptionsForCollection(string domainID, string collectionID)
        {
            Store store = Store.GetStore();

#if (!REMOVE_OLD_INVITATION)
            Domain domain = store.GetDomain(domainID);
            if ((domain != null) && (domain.SupportsNewInvitation == true))
            {
#endif
            ICSList subList = store.GetNodesByProperty(new Property(Subscription.SubscriptionCollectionIDProperty, collectionID), SearchOp.Equal);
            if (subList.Count > 0)
            {
                foreach (ShallowNode sn in subList)
                {
                    // The collection for the subscription nodes will be the POBox.
                    Collection collection = store.GetCollectionByID(sn.CollectionID);
                    if (collection != null)
                    {
                        // No need to process further invitation events. The collection associated with
                        // this subscription has already been removed.
                        Subscription subscription = new Subscription(collection, sn);
                        subscription.CascadeEvents = false;
                        collection.Commit(collection.Delete(subscription));
                        log.Debug("RemoveSubscriptionsForCollection - Removed subscription {0} for collection {1}.", sn.ID, sn.CollectionID);
                    }
                    else
                    {
                        log.Debug("RemoveSubscriptionsForCollection - Cannot find POBox {0}.", sn.CollectionID);
                    }
                }
            }
            else
            {
                log.Debug("RemoveSubscriptionsForCollection - No subscriptions found for collection {0}.", collectionID);
            }
#if (!REMOVE_OLD_INVITATION)
        }
#endif
        }
Esempio n. 25
0
        /// <summary>
        /// Creates a file type filter policy for the specified member.
        /// </summary>
        /// <param name="member">Member that the filter will be associated with.</param>
        /// <param name="patterns">File type patterns that will be used to filter files.</param>
        static public void Create(Member member, FileTypeEntry[] patterns)
        {
            ICSList ftList = new ICSList();

            // Need a policy manager.
            PolicyManager pm = new PolicyManager();

            if (patterns.Length > 0)
            {
                // Add the new rules and save the policy.
                foreach (FileTypeEntry fte in patterns)
                {
                    ftList.Add(new Rule(fte.Name, fte.IgnoreCase ? Rule.Operation.RegExp_IgnoreCase : Rule.Operation.RegExp, fte.Allowed ? Rule.Result.Allow : Rule.Result.Deny));
                }

                pm.CommitPolicy(FileTypeFilterPolicyID, ftList, member);
            }
            else
            {
                pm.DeletePolicy(FileTypeFilterPolicyID, member);
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Remove the certificate for the specified host.
        /// </summary>
        /// /// <param name="domainID">the domainid for this host</param>
        /// <param name="host">The host the certificate belongs to.</param>
        public static void RemoveDomainCertificate(string domainID, string host)
        {
            // this API is yet to be tested , and has not been used.

            string uriHost = GetHostFromUri(host);

            log.Debug("removing for host : {0}", uriHost);
            CertPolicy.RemoveCertificate(uriHost);
            log.Debug("removed for host : {0}", uriHost);

            // also remove it from store , if any
            Store  store  = Store.GetStore();
            Domain domain = store.GetDomain(domainID);

            // check for the cert
            Node    cn       = null;
            ICSList nodelist = domain.Search(hostProperty, "*", SearchOp.Equal);  //domain.GetNodesByType(CertType);

            if (nodelist == null)
            {
                log.Debug("returned null for hostproperty * ");
            }
            foreach (ShallowNode sn in nodelist)
            {
                cn = new Node(domain, sn);
                if (!cn.IsType(CertType))
                {
                    log.Debug("returned non null but this node is not of type CertType");
                    continue;
                }

                if (cn != null)
                {
                    // cert type is found
                    domain.Commit(domain.Delete(cn));
                    log.Debug("committed the deletion of certtype node for :{0} ", uriHost);
                }
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Change the default disk quota for the managed groups (falling under secondary admin) based on sync control method
        /// It will only change the default disk quota set on each group, If quota was changed by admin, thent his method will not change that.
        /// </summary>
        /// <param name="GroupQuotaRestrictionMethod">the enum which will decide what will be the default disk quota for each group</param>
        public static void ChangeDefaultGroupQuota(int GroupQuotaRestrictionMethod)
        {
            Store   store     = Store.GetStore();
            Domain  domain    = store.GetDomain(store.DefaultDomain);
            ICSList SecAdmins = domain.GetMembersByRights(Access.Rights.Secondary);

            try
            {
                foreach (ShallowNode sn in SecAdmins)
                {
                    Member AdminAsMember = new Member(domain, sn);
                    if (!AdminAsMember.IsType("Host"))
                    {
                        string [] ManagedGroups = AdminAsMember.GetMonitoredGroups();
                        foreach (string GroupID in ManagedGroups)
                        {
                            Member GroupAsMember  = domain.GetMemberByID(GroupID);
                            long   GroupDiskQuota = Simias.Policy.DiskSpaceQuota.Get(GroupAsMember).Limit;
                            if (GroupQuotaRestrictionMethod == (int)QuotaRestriction.UI_Based && GroupDiskQuota == -1)
                            {
                                // change the default disk quota for groups, (from Unlimited to 0MB)
                                Simias.Policy.DiskSpaceQuota.Set(GroupAsMember, 0);
                            }
                            else if (GroupQuotaRestrictionMethod == (int)QuotaRestriction.Sync_Based && GroupDiskQuota == 0)
                            {
                                // change the default disk quota for groups, (from 0MB to Unlimited)
                                Simias.Policy.DiskSpaceQuota.Delete(GroupAsMember);
                            }
                        }
                    }
                }
                domain.Commit();
            }
            catch (Exception ex)
            {
                log.Debug("Exception during changing the default disk quota. " + ex.ToString());
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Starts a search for a specific set of domain members.
        /// </summary>
        /// <param name="domainID">The identifier of the domain to search for members in.</param>
        /// <param name="attributeName">Name of attribute to search.</param>
        /// <param name="searchString">String that contains a pattern to search for.</param>
        /// <param name="operation">Type of search operation to perform.</param>
        /// <param name="count">Maximum number of member objects to return.</param>
        /// <param name="searchContext">Receives a provider specific search context object. This object must be serializable.</param>
        /// <param name="memberList">Receives an array object that contains the domain Member objects.</param>
        /// <param name="total">Receives the total number of objects found in the search.</param>
        /// <returns>True if there are more domain members. Otherwise false is returned.</returns>
        public bool FindFirstDomainMembers(string domainID, string attributeName, string searchString, SearchOp operation, int count, out string searchContext, out Member[] memberList, out int total)
        {
            bool moreEntries = false;

            // Initialize the outputs.
            searchContext = null;
            memberList    = null;
            total         = 0;

            // Start the search for the specific members of the domain.
            Domain domain = store.GetDomain(domainID);

            if (domain != null)
            {
                ICSList     list        = domain.Search(attributeName, searchString, operation);
                SearchState searchState = new SearchState(domainID, list.GetEnumerator() as ICSEnumerator, list.Count);
                searchContext = searchState.ContextHandle;
                total         = list.Count;
                moreEntries   = FindNextDomainMembers(ref searchContext, count, out memberList);
            }

            return(moreEntries);
        }
Esempio n. 29
0
    // open store and enable the login for all users. It will also delete 'DisabledAt' property for all users, if it was set earlier.
    //DisabledAt property means during e-dir sync, somehow server interpreted that user was deleted in e-dir, so disabled in iFolder and currently
    // it is under grace itnerval period. After grace interval, server will completely delete that user and orphan his iFolders.
    public static void EnableUserLogins(bool replace)
    {
        if (replace == false)
        {
            Console.WriteLine("You have opted to view and not delete..Use enable to modify also ");
        }
        else
        {
            Console.WriteLine("It will modify the members");
        }
        Store.Initialize(SimiasDataPath, true, -1);
        Store store = Store.GetStore();

        if (store == null)
        {
            Console.WriteLine("store could not be initialized.....");
        }
        Domain domain = store.GetDomain(store.DefaultDomain);

        try{
            ICSList FullMemList = domain.GetMemberList();
            foreach (ShallowNode sn in FullMemList)
            {
                Member memObject = new Member(domain, sn);
                Simias.Storage.Property disabledAt = memObject.Properties.GetSingleProperty(disabledAtProperty);
                if (disabledAt != null)
                {
                    if (replace)
                    {
                        memObject.DeleteProperty = disabledAtProperty;
                    }

                    if (domain.GetLoginpolicy(memObject.UserID) == true)                          //it returns true if user is disabled
                    {
                        // if login was disabled, then enable login
                        if (replace == true)
                        {
                            domain.SetLoginDisabled(memObject.UserID, false);                               //false means it will delete the logindisabled property
                        }
                        Console.WriteLine("Enabled the login for user :"******"Login already enabled for user :"******"Removed the disabledAt property for user :"******"Got exception: " + ee.Message);
        }
        finally{
            Store.DeleteInstance();
        }
    }
Esempio n. 30
0
        /// <summary>
        /// write the response back
        /// </summary>
        public void Send()
        {
            ctx.Response.Write("<channel>");

            ctx.Response.Write("<title>");
            ctx.Response.Write(collection.Name);
            ctx.Response.Write("</title>");

            /*
             * if (slog.Link != "")
             * {
             *      ctx.Response.Write("<link>");
             *      ctx.Response.Write( slog.Link );
             *      ctx.Response.Write("</link>");
             * }
             */

            ctx.Response.Write("<language>");
            ctx.Response.Write("en-us");
            ctx.Response.Write("</language>");

            ctx.Response.Write("<copyright>");
            ctx.Response.Write("(c) Novell, Inc.");
            ctx.Response.Write("</copyright>");

            ctx.Response.Write("<managingEditor>");
            Domain domain = store.GetDomain(store.DefaultDomain);

            if (collection.Owner.FN != null && collection.Owner.FN != "")
            {
                ctx.Response.Write(collection.Owner.FN);
            }
            else
            {
                ctx.Response.Write(collection.Owner.Name);
            }
            ctx.Response.Write("</managingEditor>");

            ctx.Response.Write("<webmaster>");
            //member = domain.GetMemberByID( domain.Owner );
            if (domain.Owner.FN != null && domain.Owner.FN != "")
            {
                ctx.Response.Write(domain.Owner.FN);
            }
            else
            {
                ctx.Response.Write(domain.Owner.Name);
            }
            ctx.Response.Write("</webmaster>");

            try
            {
                Simias.Storage.Property descProp =
                    collection.Properties.GetSingleProperty("Description");
                if (descProp != null)
                {
                    ctx.Response.Write("<description>" + descProp.Value.ToString() + "</description>");
                }
                else
                {
                    ctx.Response.Write("<description>" + collection.Type.ToString() + "</description>");
                }
            }
            catch {}

            ctx.Response.Write(
                String.Format(
                    "<link>{0}{1}:{2}{3}{4}?feed={5}</link>",
                    ctx.Request.IsSecureConnection ? "https://" : "http://",
                    ctx.Request.Url.Host,
                    ctx.Request.Url.Port.ToString(),
                    ctx.Request.ApplicationPath,
                    (publicAccess == true) ? "/pubrss.ashx" : "/rss.ashx",
                    HttpUtility.UrlEncode(collection.Name)));

            Simias.Storage.Property colProp =
                collection.Properties.GetSingleProperty(Simias.RssFeed.Util.LastModified);
            DateTime latest = (colProp != null) ? (DateTime)colProp.Value : collection.CreationTime;


            /*
             * ICSList nodes = collection.Search( Simias.RssFeed.Util.LastModified, dt, SearchOp.Greater );
             * ICSEnumerator nodesEnum = null;
             * if ( nodes.Count > 0 )
             * {
             *      nodesEnum = nodes.GetEnumerator() as ICSEnumerator;
             *      if ( nodesEnum != null &&
             *                      nodesEnum.SetCursor( IndexOrigin.SET, nodesEnum.Count - 1 ) == true )
             *      {
             *              nodesEnum.MoveNext();
             *
             *              try
             *              {
             *                      ShallowNode sn = nodesEnum.Current as ShallowNode;
             *                      log.Debug( "sn: " + sn.Name );
             *
             *                      Item item = new Item( collection, sn );
             *                      if ( item.Published > latest )
             *                      {
             *                              latest = item.Published;
             *                      }
             *              }
             *              catch( Exception e )
             *              {
             *                      log.Debug( e.Message );
             *              }
             *      }
             * }
             */

            Simias.RssFeed.Util.SendPublishDate(ctx, latest);

            ctx.Response.Write("<lastBuildDate>");
            ctx.Response.Write(Util.GetRfc822Date(latest));
            ctx.Response.Write("</lastBuildDate>");

            ctx.Response.Write("<generator>");
            ctx.Response.Write("Simias");
            ctx.Response.Write("</generator>");

            /*
             *      ctx.Response.Write("<cloud>");
             *      ctx.Response.Write( node.Cloud );
             *      ctx.Response.Write("</cloud>");
             */

            ctx.Response.Write("<ttl>");
            ctx.Response.Write(Simias.RssFeed.Util.DefaultTtl.ToString());
            ctx.Response.Write("</ttl>");

            ctx.Response.Write("<rating>");
            ctx.Response.Write(Simias.RssFeed.Util.DefaultRating);
            ctx.Response.Write("</rating>");

            if (strict == false)
            {
                ctx.Response.Write("<authorID>" + collection.Owner.UserID + "</authorID>");
                ctx.Response.Write("<type>" + collection.Type.ToString() + "</type>");
                ctx.Response.Write("<id>" + collection.ID + "</id>");
            }

            if (items == true)
            {
                ICSList nodes =
                    collection.Search(
                        Simias.RssFeed.Util.LastModified,
                        new DateTime(1992, 1, 1, 0, 0, 0),
                        SearchOp.Greater);
                if (nodes != null && nodes.Count > 0)
                {
                    ICSEnumerator nodesEnum = nodes.GetEnumerator() as ICSEnumerator;
                    int           count     = nodesEnum.Count;
                    while (count-- > 0)
                    {
                        if (nodesEnum.SetCursor(IndexOrigin.SET, count) == true)
                        {
                            nodesEnum.MoveNext();
                            ShallowNode sn   = nodesEnum.Current as ShallowNode;
                            Item        item = null;
                            if (this.types.Count == 0)
                            {
                                if (sn.Type == "FileNode")
                                {
                                    item = new Item(collection, sn, publicAccess);
                                }
                            }
                            else
                            {
                                foreach (string ctype in this.types)
                                {
                                    if (ctype == sn.Type)
                                    {
                                        item = new Item(collection, sn, publicAccess);
                                        break;
                                    }
                                }
                            }

                            if (item != null)
                            {
                                item.Strict     = this.strict;
                                item.Enclosures = this.enclosures;
                                item.Send(ctx);
                            }
                        }
                    }
                }
            }

            ctx.Response.Write("</channel>");
        }