Example #1
0
        /// <summary>
        /// Gets the list of hosted members of a domain
        /// </summary>
        /// <returns>ICSList with host members</returns>
        public ICSList GetHostedMembers()
        {
            Store  store  = Store.GetStore();
            Domain domain = store.GetDomain(GetDomainID(store));

            return(domain.Search(PropertyTags.HostID, this.UserID, SearchOp.Equal));
        }
Example #2
0
        /// <summary>
        /// Gets the local host
        /// </summary>
        /// <returns>Hostnode with local host details</returns>
        public static HostNode GetLocalHost()
        {
            Store  store  = Store.GetStore();
            Domain domain = null;

            // this might given an exception if the Default Domain is not set up.
            // this is true when the entire iFolder store is restored - so the try/catch
            // Need to find a better way to fix this without try/catch - FIXME
            try
            {
                domain = store.GetDomain(store.DefaultDomain);
                ICSList searchList = domain.Search(LocalHostTag, Syntax.Boolean, SearchOp.Exists);
                if (searchList.Count == 1)
                {
                    IEnumerator list = searchList.GetEnumerator();
                    list.MoveNext();
                    ShallowNode sn = (ShallowNode)list.Current;
                    return(new HostNode(domain.GetNodeByID(sn.ID)));
                }
                else if (!Store.IsEnterpriseServer)
                {
                    return(domain.Host);
                }
                return(null);
            }
            catch
            {
                return(null);
            }
        }
Example #3
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);
        }
Example #4
0
        /// <summary>
        /// Gets the master in a domain
        /// </summary>
        /// <param name="domainId">Domain ID for which master details needed</param>
        /// <returns>Returns the HostNode of master</returns>
        public static HostNode GetMaster(string domainId)
        {
            Domain  domain     = Store.GetStore().GetDomain(domainId);
            ICSList searchList = domain.Search(PropertyTags.MasterHost, Syntax.Boolean, SearchOp.Exists);

            if (searchList.Count == 1)
            {
                IEnumerator list = searchList.GetEnumerator();
                list.MoveNext();
                ShallowNode sn = (ShallowNode)list.Current;
                return(new HostNode(domain.GetNodeByID(sn.ID)));
            }
            return(null);
        }