コード例 #1
0
ファイル: User.cs プロジェクト: lulzzz/ifolder
        /// <summary>
        /// commit the encrypted password as part of member object
        /// </summary>
        /// <returns>true if setting is successful</returns>
        private bool SetAdminPassword()
        {
            bool status = false;

            // Bootstrap the domain from the Simias.config file
            Simias.Configuration config = Store.Config;
            string adminName            = config.Get("EnterpriseDomain", "AdminName");
            string adminPassword        = config.Get("EnterpriseDomain", "AdminPassword");

            if (adminName != null && adminName != "" && adminPassword != null)
            {
                try
                {
                    Member member = domain.GetMemberByName(adminName);
                    if (member != null)
                    {
                        Property pwd =
                            member.Properties.GetSingleProperty(InternalUser.pwdProperty);
                        if (pwd == null || pwd.Value == null)
                        {
                            pwd = new Property(InternalUser.pwdProperty, HashPassword(adminPassword));
                            member.Properties.ModifyProperty(pwd);

                            // Marker so we know this member was created internally
                            // and not through an external identity sync.
                            domain.SetType(member as Node, InternalUser.memberMarker);
                            domain.Commit(member);
                            status = true;
                        }
                    }
                }
                catch (Exception ap)
                {
                    log.Error(ap.Message);
                    log.Error(ap.StackTrace);
                }
            }

            return(status);
        }
コード例 #2
0
        /// <summary>
        /// Method to get the Simias Enterprise server domain
        /// If the the domain does not exist and the create flag is true
        /// the domain will be created.  If create == false, ownerName is ignored
        /// </summary>
        internal Simias.Storage.Domain GetServerDomain(bool Create)
        {
            //  Check if the Server domain exists in the store
            Simias.Storage.Domain enterpriseDomain = null;
            bool master = true;

            try
            {
                Collection collection = store.GetSingleCollectionByType("Enterprise");
                if (collection != null)
                {
                    enterpriseDomain = store.GetDomain(collection.ID);
                    if (enterpriseDomain != null)
                    {
                        this.domainName = enterpriseDomain.Name;
                        this.id         = enterpriseDomain.ID;

                        // For backwards compatibility, if the report collection does not
                        // exist because the store was created with a previous version of
                        // simias, check and create it here.
                        // Don't create this directory on a slave server.

                        //TODO : Check with migration !!
                        Report.CreateReportCollection(store, enterpriseDomain);
                    }
                }

                if (enterpriseDomain == null && Create == true)
                {
                    // Bootstrap the domain from the Simias.config file
                    Simias.Configuration config = Store.Config;
                    string cfgValue             = config.Get("EnterpriseDomain", "SystemName");
                    if (cfgValue != null && cfgValue != String.Empty)
                    {
                        this.domainName = cfgValue;
                    }

                    cfgValue = config.Get("EnterpriseDomain", "Description");
                    if (cfgValue != null && cfgValue != String.Empty)
                    {
                        this.description = cfgValue;
                    }

                    cfgValue = config.Get("EnterpriseDomain", "AdminName");
                    if (cfgValue != null && cfgValue != String.Empty)
                    {
                        this.admin = cfgValue;
                    }

                    cfgValue = config.Get("Server", "MasterAddress");
                    if (cfgValue != null && cfgValue != String.Empty)
                    {
                        master = false;
                    }

                    /*
                     * cfgValue = config.Get( "EnterpriseDomain", "AdminPassword" );
                     * if ( cfgValue != null && cfgValue != "" )
                     * {
                     *      this.adminPassword = cfgValue;
                     * }
                     */

                    if (master == true)
                    {
                        cfgValue = config.Get("EnterpriseDomain", "DomainID");
                        if (cfgValue != null && cfgValue != String.Empty)
                        {
                            this.id = cfgValue;
                        }
                        else
                        {
                            this.id = Guid.NewGuid().ToString();
                        }

                        // Create the enterprise server domain.
                        enterpriseDomain =
                            new Simias.Storage.Domain(
                                store,
                                this.domainName,
                                this.id,
                                this.description,
                                Simias.Sync.SyncRoles.Master,
                                Simias.Storage.Domain.ConfigurationType.ClientServer);

                        // This needs to be added to allow the enterprise location provider
                        // to be able to resolve this domain.
                        enterpriseDomain.SetType(enterpriseDomain, "Enterprise");

                        // Create the owner member for the domain.
                        string provider = null;
                        cfgValue = config.Get("Identity", "Assembly");
                        if (cfgValue != null && cfgValue != String.Empty)
                        {
                            provider = cfgValue;
                        }

                        this.admin = ParseUserName(this.admin, provider);

                        Member member =
                            new Member(this.admin, Guid.NewGuid().ToString(), Access.Rights.Admin);

                        member.IsOwner = true;
                        enterpriseDomain.SetType(member as Node, "User");

                        // Marker so we know this member was created internally
                        // and not through an external identity sync.
                        enterpriseDomain.SetType(member as Node, "Internal");

                        enterpriseDomain.Commit(new Node[] { enterpriseDomain, member });

                        // Set the domain default
                        store.DefaultDomain = enterpriseDomain.ID;

                        // Create the name mapping.
                        store.AddDomainIdentity(enterpriseDomain.ID, member.UserID);
                    }
                    else
                    {
                        // Slave host so create the proxy domain and owner.
                        enterpriseDomain      = Simias.Host.SlaveSetup.GetDomain(Store.StorePath);
                        store.DefaultDomain   = enterpriseDomain.ID;
                        enterpriseDomain.Role = Simias.Sync.SyncRoles.Slave;
                        Member owner = Simias.Host.SlaveSetup.GetOwner(Store.StorePath);
                        enterpriseDomain.SetType(enterpriseDomain, "Enterprise");
                        enterpriseDomain.Proxy = true;
                        owner.Proxy            = true;
                        enterpriseDomain.Commit(new Node[] { enterpriseDomain, owner });
                    }

                    Report.CreateReportCollection(store, enterpriseDomain);
                }
            }
            catch (Exception gssd)
            {
                log.Error(gssd.Message);
                log.Error(gssd.StackTrace);
            }

            return(enterpriseDomain);
        }
コード例 #3
0
ファイル: GaimDomain.cs プロジェクト: RoDaniel/featurehouse
 private void Init()
 {
     hostAddress = MyDns.GetHostName();
        Store store = Store.GetStore();
        try
        {
     Uri localUri = Manager.LocalServiceUrl;
     Simias.Storage.Domain rDomain = store.GetDomain( ID );
     if (rDomain == null)
     {
      rDomain =
       new Simias.Storage.Domain(
        store,
        this.domainName,
        Simias.Gaim.GaimDomain.ID,
        this.description,
        Simias.Sync.SyncRoles.Master,
        Simias.Storage.Domain.ConfigurationType.Workgroup );
      rDomain.SetType( rDomain, "Workgroup" );
      string storedUserID = GetGaimUserID();
      if (storedUserID != null)
      {
       log.Debug("Creating the Gaim Domain with a saved UserID");
       userID = storedUserID;
      }
      else
      {
       log.Debug("Creating the Gaim Domain with a NEW UserID");
       userID = Guid.NewGuid().ToString();
      }
      Member member =
       new Member(
        userName,
        userID,
        Access.Rights.Admin );
      member.IsOwner = true;
      if (localUri == null)
      {
       localUri = Manager.LocalServiceUrl;
       if (localUri != null)
       {
        Simias.Storage.Property p = new Property("Gaim:SimiasURL", localUri.ToString());
        p.LocalProperty = true;
        member.Properties.AddProperty(p);
       }
       else
       {
        log.Debug("Manager.LocalServiceUrl returned NULL!");
       }
      }
      if (aliasName != null && aliasName.Length > 0)
      {
       Simias.Storage.Property p = new Property("Gaim:Alias", aliasName);
       p.LocalProperty = true;
       member.FN = string.Format("{0} ({1})", aliasName, hostName);
      }
      rDomain.Commit( new Node[] { rDomain, member } );
      store.AddDomainIdentity( rDomain.ID, member.UserID );
      GaimService.RegisterDomainProvider();
     }
     Member pMember;
     Simias.POBox.POBox poBox = null;
     string poBoxName = "POBox:" + Simias.Gaim.GaimDomain.ID + ":" + userID;
     try
     {
      poBox = Simias.POBox.POBox.FindPOBox( store, Simias.Gaim.GaimDomain.ID, userID );
     }
     catch{}
     if (poBox == null)
     {
      poBox = new Simias.POBox.POBox( store, poBoxName, ID );
      pMember =
       new Member( userName, userID, Access.Rights.ReadWrite );
      pMember.IsOwner = true;
      poBox.Commit(new Node[] { poBox, pMember });
     }
     else
     {
      pMember = poBox.GetMemberByID( userID );
      if (pMember == null)
      {
       pMember =
        new Member( userName, userID, Access.Rights.ReadWrite );
       pMember.IsOwner = true;
       poBox.Commit(new Node[] { pMember });
      }
     }
     poBoxID = poBox.ID;
        }
        catch( Exception e1 )
        {
     log.Error(e1.Message);
     log.Error(e1.StackTrace);
     throw e1;
        }
 }