public void Find_IfUsingAAuthenticablePrincipalQueryFilter_ShouldReturnAResultWithComputersAndUsers()
        {
            var principalRepository = new PrincipalRepository(CreateDefaultDomainPrincipalConnection());

            var structuralObjectClasses = new List <string>();
            var principalTypes          = new List <Type>();

            using (var queryFilter = new AuthenticablePrincipalQueryFilter())
            {
                using (var searchResult = principalRepository.Find(queryFilter))
                {
                    foreach (var item in searchResult)
                    {
                        if (!structuralObjectClasses.Contains(item.StructuralObjectClass, StringComparer.OrdinalIgnoreCase))
                        {
                            structuralObjectClasses.Add(item.StructuralObjectClass);
                        }

                        if (!principalTypes.Contains(item.GetType()))
                        {
                            principalTypes.Add(item.GetType());
                        }
                    }
                }
            }

            Assert.AreEqual(2, structuralObjectClasses.Count);

            Assert.IsTrue(structuralObjectClasses.Contains("computer"));
            Assert.IsTrue(structuralObjectClasses.Contains("user"));

            Assert.AreEqual(1, principalTypes.Count);

            Assert.IsTrue(principalTypes.Contains(typeof(AuthenticablePrincipalWrapper)));
        }
        public void Get_IfGettingAGroupPrincipal_ItShouldBeAbleToIterateItsMembers()
        {
            var memberNames = new List <string>();

            var principalRepository = new PrincipalRepository(CreateDefaultDomainPrincipalConnection());

            using (var groupPrincipal = principalRepository.Get <IGroupPrincipal>("Domain Users", IdentityType.Name))
            {
                using (var members = groupPrincipal.GetMembers())
                {
                    foreach (var member in members)
                    {
                        using (member)
                        {
                            memberNames.Add(member.Name);
                        }
                    }
                }
            }

            Assert.AreEqual(6, memberNames.Count);

            Assert.AreEqual("Administrator", memberNames.ElementAt(0));
            Assert.AreEqual("krbtgt", memberNames.ElementAt(1));
            Assert.AreEqual("FirstName01 LastName01", memberNames.ElementAt(2));
            Assert.AreEqual("FirstName02 LastName02", memberNames.ElementAt(3));
            Assert.AreEqual("User03", memberNames.ElementAt(4));
            Assert.AreEqual("User1000", memberNames.ElementAt(5));
        }
コード例 #3
0
 public ACLReport(IRepository <Principal, string> prinRepository,
                  IRepository <CalendarCollection, string> colRepository,
                  IRepository <CalendarResource, string> resRepository)
 {
     _principalRepository  = prinRepository as PrincipalRepository;
     _collectionRepository = _collectionRepository;
     _resourceRepository   = resRepository as ResourceRespository;
 }
        public void Create_ShouldHandleUserPrincipal()
        {
            var principalRepository = new PrincipalRepository(CreateDefaultDomainPrincipalConnection());

            using (var userPrincipal = principalRepository.Create <IUserPrincipal>())
            {
                Assert.IsNotNull(userPrincipal);
            }
        }
コード例 #5
0
ファイル: CalDav.cs プロジェクト: flechilla/CalDavServer
 /// <summary>
 ///     DI in the params.
 /// </summary>
 /// <param name="fsManagement"></param>
 /// <param name="aclProfind"></param>
 /// <param name="collectionCollectionReport"></param>
 /// <param name="collectionRespository"></param>
 /// <param name="resourceRespository"></param>
 /// <param name="principalRepository"></param>
 public CalDav(IFileSystemManagement fsManagement, IACLProfind aclProfind,
               ICollectionReport collectionCollectionReport, IRepository <CalendarCollection,
                                                                          string> collectionRespository, IRepository <CalendarResource, string> resourceRespository,
               IRepository <Principal, string> principalRepository)
 {
     StorageManagement          = fsManagement;
     _aclProfind                = aclProfind;
     _colectionCollectionReport = collectionCollectionReport;
     _collectionRespository     = collectionRespository as CollectionRepository;
     _principalRepository       = principalRepository as PrincipalRepository;
     _resourceRespository       = resourceRespository as ResourceRespository;
 }
コード例 #6
0
        public void UnitTest4()
        {
            using (var context = new CalDavContext())
            {
                var prinRepository = new PrincipalRepository(context);
                prinRepository.CreateStudentInSystem("*****@*****.**", "Student1", _password, _career, _group,
                                                     _year);
                context.SaveChanges();
                var user = context.Students.FirstOrDefaultAsync(x => x.Email == _email && x.Career == _career);

                Assert.NotNull(user);
            }
        }
コード例 #7
0
 public UnitOfWork(Model1 dbContext)
 {
     _dbContext                 = dbContext;
     StudentRepository          = new StudentRepository(_dbContext);
     TeacherRepository          = new TeacherRepository(_dbContext);
     PrincipalRepository        = new PrincipalRepository(_dbContext);
     UserRepository             = new UserRepository(_dbContext);
     School_SubjectsRepository  = new School_SubjectsRepository(_dbContext);
     SessionRepository          = new SessionRepository(_dbContext);
     Teachers_ClassesRepository = new Teachers_ClassesRepository(_dbContext);
     dClassRepository           = new ClassRepository(_dbContext);
     SubjectsRepository         = new SubjectsRepository(_dbContext);
     //add other repositories here
 }
コード例 #8
0
        private void LoadProjectData()
        {
            ArrayList allProjects = new PLProject().GetAllProjects(ClientData.LogonUser.Oid);

            this.lv_projects.Items.Clear();
            foreach (DEProject project2 in allProjects)
            {
                ListViewItem item = new ListViewItem {
                    Text     = project2.Name,
                    SubItems = { PrincipalRepository.GetPrincipalName(project2.Project_manager) },
                    Tag      = project2
                };
                this.lv_projects.Items.Add(item);
            }
        }
コード例 #9
0
        public void UnitTest9()
        {
            var context        = new CalDavContext(new DbContextOptions <CalDavContext>());
            var prinRepository = new PrincipalRepository(context);

            var user = prinRepository.CreateWorkerInSystem("*****@*****.**", "worker", "UnitTest9 worker", _faculty,
                                                           "Weboo");

            context.SaveChanges();
            Assert.True(context.Workers.Count() > 0);

            var worker = context.Workers.FirstOrDefault(x => x.Email == "*****@*****.**");

            Assert.NotNull(worker);
            Assert.NotNull(context.Principals.FirstOrDefault(x => x.PrincipalId == worker.PrincipalId.Value));
            Assert.NotNull(context.CalendarCollections.FirstOrDefault(x => x.PrincipalId == worker.PrincipalId.Value));
        }
コード例 #10
0
        public async Task UnitTest1()
        {
            var context = new CalDavContext(new DbContextOptions <CalDavContext>());

            var prinRepository = new PrincipalRepository(context);

            var user = prinRepository.CreateUserInSystem(_email, _fullName, _password);

            Assert.NotNull(user);

            context.SaveChanges();
            Assert.True(context.Users.Any());

            var dbUser = context.Users.FirstOrDefault(x => x.Email == _email);

            Assert.NotNull(dbUser);

            Assert.True(await prinRepository.ExistByStringIs(_email));
        }
コード例 #11
0
 public UnitofWork(QuonDbContext context)
 {
     _context                      = context;
     EmployeeRepository            = new EmployeeRepository(_context);
     PersonRepository              = new PersonRepository(_context);
     EmployeeStationRepository     = new EmployeeStationRepository(_context);
     EmployeePositionRepository    = new EmployeePositionRepository(_context);
     EmployeeDesignationRepository = new EmployeeDesignationRepository(_context);
     PositionRepository            = new PositionRepository(_context);
     StationRepository             = new StationRepository(_context);
     PrincipalRepository           = new PrincipalRepository(_context);
     UserRepository                = new UserRepository(_context);
     RoleRepository                = new RoleRepository(_context);
     RoleAccessRepository          = new RoleAccessRepository(_context);
     StudentRepository             = new StudentRepository(_context);
     SectionRepository             = new SectionRepository(_context);
     LevelSectionRepository        = new LevelSectionRepository(_context);
     SectionAdviserRepository      = new SectionAdviserRepository(_context);
     LevelRepository               = new LevelRepository(_context);
     AdviserRepository             = new AdviserRepository(_context);
 }
コード例 #12
0
ファイル: FrmBrowse.cs プロジェクト: funtomi/MyNewCode
 private void FillListViewItem(ListViewItem lvi, DEItemMaster2 mas, DEItemRevision2 rev)
 {
     lvi.SubItems.Clear();
     lvi.Text = mas.Id;
     lvi.SubItems.Add(rev.Revision.ToString());
     lvi.SubItems.Add(rev.LastIteration.ToString());
     lvi.SubItems.Add(this.GetRealeaseDescLabel(rev));
     lvi.SubItems.Add(mas.StateLabel);
     lvi.SubItems.Add(PrincipalRepository.GetPrincipalName(mas.Holder));
     lvi.SubItems.Add(PrincipalRepository.GetPrincipalName(rev.Creator));
     lvi.SubItems.Add(rev.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
     if (mas.State == ItemState.Release)
     {
         lvi.SubItems.Add(PrincipalRepository.GetPrincipalName(rev.Releaser));
         lvi.SubItems.Add(rev.ReleaseTime.ToString("yyyy-MM-dd HH:mm:ss"));
     }
     else
     {
         lvi.SubItems.Add("");
         lvi.SubItems.Add("");
     }
 }
コード例 #13
0
ファイル: FrmBrowse.cs プロジェクト: funtomi/MyNewCode
 private void FillListViewItemSimple(ListViewItem item, DEItemMaster2 mas, DEItemRevision2 rev)
 {
     item.SubItems.Clear();
     item.Text = mas.Id;
     this.lvwTemplates.SetColumnSortFormat(2, SortedListViewFormatType.String);
     if (this.lvwTemplates.Columns.Contains(this.colIteration))
     {
         this.lvwTemplates.Columns.Remove(this.colIteration);
     }
     if (this.lvwTemplates.Columns.Contains(this.colState))
     {
         this.lvwTemplates.Columns.Remove(this.colState);
     }
     if (this.lvwTemplates.Columns.Contains(this.colHolder))
     {
         this.lvwTemplates.Columns.Remove(this.colHolder);
     }
     item.SubItems.Add(rev.Revision.ToString());
     item.SubItems.Add(this.GetRealeaseDescLabel(rev));
     item.SubItems.Add(PrincipalRepository.GetPrincipalName(rev.Creator));
     item.SubItems.Add(rev.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"));
     item.SubItems.Add(PrincipalRepository.GetPrincipalName(rev.Releaser));
     item.SubItems.Add(rev.ReleaseTime.ToString("yyyy-MM-dd HH:mm:ss"));
 }
        public void Save_ShouldHandleUserPrincipal()
        {
            const string userName = "******";

            var principalRepository = new PrincipalRepository(CreateDefaultDomainPrincipalConnection());

            using (var userPrincipalQueryFilter = new UserPrincipalQueryFilter())
            {
                userPrincipalQueryFilter.SamAccountName = userName;

                using (var foundUserPrincipals = principalRepository.Find(userPrincipalQueryFilter))
                {
                    if (foundUserPrincipals.Any())
                    {
                        if (foundUserPrincipals.Count() > 1)
                        {
                            throw new InvalidOperationException("There should not be duplicates of a user.");
                        }

                        var userPrincipal = (IUserPrincipal)foundUserPrincipals.ElementAt(0);

                        principalRepository.Delete(userPrincipal);
                    }
                }
            }

            using (var userPrincipal = principalRepository.Create <IUserPrincipal>())
            {
                userPrincipal.Enabled = true;
                userPrincipal.PasswordNeverExpires = true;
                userPrincipal.SamAccountName       = userName;
                userPrincipal.SetPassword("P@ssword");

                principalRepository.Save(userPrincipal);
            }
        }
コード例 #15
0
 public PrincipalController()
 {
     _principalRepository = new PrincipalRepository();
 }
コード例 #16
0
 public PrincipalService(string connectionString)
 {
     conexion   = new ConnectionManager(connectionString);
     repository = new PrincipalRepository(conexion);
 }
コード例 #17
0
 /// <summary>
 ///     Injects an instance of CaldavContext
 /// </summary>
 /// <param name="context"></param>
 public UhCalendarAuthentication(IRepository <Principal, string> principalRepository)
 {
     _principalRepository = principalRepository as PrincipalRepository;
 }
コード例 #18
0
 public PrincipalService()
 {
     connection = new SqlConnection(CadenaConexion);
     repository = new PrincipalRepository(connection);
 }
コード例 #19
0
ファイル: Global.asax.cs プロジェクト: ARLM-Attic/clr-toolbox
        protected void Application_Start(object sender, EventArgs e)
        {
            var rootDir = new DirectoryInfo(this.Server.MapPath("~/bin"));

            // app context
            var app = new CloudApp();
            {
                IConfigRepository config;
                var configIni = new FileInfo(Path.Combine(rootDir.FullName,
                                                          "config.ini"));
                if (configIni.Exists)
                {
                    config = new IniFileConfigRepository(configIni);
                }
                else
                {
                    config = new KeyValuePairConfigRepository();
                }

                app.Config = config.MakeReadOnly();
            }

            // principal repository
            var pricRepo = new PrincipalRepository();

            {
                pricRepo.LocalDataDirectory = rootDir.FullName;
                {
                    string temp;
                    if (app.Config.TryGetValue <string>("Data", out temp, "Directories") &&
                        string.IsNullOrWhiteSpace(temp) == false)
                    {
                        pricRepo.LocalDataDirectory = temp.Trim();
                    }
                }

                var iniFile = new FileInfo(Path.Combine(rootDir.FullName, "users.ini"));
                if (iniFile.Exists)
                {
                    pricRepo.UserRepository = new IniFileConfigRepository(iniFile);
                }

                pricRepo.Reload();
            }

            // URL routes
            {
                // files
                RouteTable.Routes.Add(new Route
                                      (
                                          "files",
                                          new FilesHttpHandler()
                                      ));

                // messages
                RouteTable.Routes.Add(new Route
                                      (
                                          "messages",
                                          new MessagesHttpHandler()
                                      ));
            }

            // ServiceLocator
            {
                this.GlobalCompositionCatalog = new AggregateCatalog();
                this.GlobalCompositionCatalog.Catalogs.Add(new AssemblyCatalog(typeof(global::MarcelJoachimKloubert.CloudNET.Classes.ICloudApp).Assembly));

                this.GlobalCompositionContainer = new CompositionContainer(this.GlobalCompositionCatalog, true);
                this.GlobalCompositionContainer.ComposeExportedValue <global::MarcelJoachimKloubert.CloudNET.Classes.ICloudApp>(app);
                this.GlobalCompositionContainer.ComposeExportedValue <global::MarcelJoachimKloubert.CloudNET.Classes.Security.IPrincipalRepository>(pricRepo);
                this.GlobalCompositionContainer.ComposeExportedValue <global::System.Web.HttpApplication>(this);

                var innerLocator = new ExportProviderServiceLocator(this.GlobalCompositionContainer);

                this.GlobalServiceLocator = new DelegateServiceLocator(innerLocator);

                this.GlobalCompositionContainer.ComposeExportedValue <global::MarcelJoachimKloubert.CLRToolbox.ServiceLocation.IServiceLocator>(this.GlobalServiceLocator);
                this.GlobalCompositionContainer.ComposeExportedValue <global::MarcelJoachimKloubert.CLRToolbox.ServiceLocation.Impl.DelegateServiceLocator>(this.GlobalServiceLocator);
                this.GlobalCompositionContainer.ComposeExportedValue <global::MarcelJoachimKloubert.CLRToolbox.ServiceLocation.Impl.ExportProviderServiceLocator>(innerLocator);

                ServiceLocator.SetLocator(this.GlobalServiceLocator);
            }

            this.Application[APP_VAR_APPCONTEXT] = app;
            this.Application[APP_VAR_PRINCIPALS] = pricRepo;
        }
コード例 #20
0
ファイル: ResDataToExcel.cs プロジェクト: funtomi/MyNewCode
        private void ConvertToListView()
        {
            DataView  defaultView = null;
            DataTable table       = new DataTable();

            if (this.IsMultiPageOut)
            {
                this.lvw.Items.Clear();
            }
            defaultView = this.theDataSet.Tables[0].DefaultView;
            if (defaultView.Table.Rows.Count != 0)
            {
                int num = 0;
                foreach (DataRowView view2 in defaultView)
                {
                    int    num2       = 0;
                    string columnName = "";
                    table.NewRow();
                    ListViewItem item = new ListViewItem();
                    for (int i = 0; i < defaultView.Table.Columns.Count; i++)
                    {
                        foreach (DEMetaAttribute attribute in this.attrList)
                        {
                            if (this.ISDefAttrViewable(attribute) && (defaultView.Table.Columns[i].ColumnName == ("PLM_" + attribute.Name)))
                            {
                                columnName = "PLM_" + attribute.Name;
                                if (this.b_refType)
                                {
                                    if (((attribute.Name == "R_CREATOR") || (attribute.Name == "LATESTUPDATOR")) && (attribute.DataType == 8))
                                    {
                                        string principalName = PrincipalRepository.GetPrincipalName(new Guid((byte[])view2[columnName]));
                                        if (num2 == 0)
                                        {
                                            item.Text = principalName;
                                        }
                                        else
                                        {
                                            item.SubItems.Add(principalName);
                                        }
                                    }
                                    else if (attribute.Name == "M_CLASS")
                                    {
                                        string classname = view2[columnName].ToString();
                                        if (num2 == 0)
                                        {
                                            item.Text = ModelContext.MetaModel.GetClassLabel(classname);
                                        }
                                        else
                                        {
                                            item.SubItems.Add(ModelContext.MetaModel.GetClassLabel(classname));
                                        }
                                    }
                                    else if (attribute.Name == "R_REVSTATE")
                                    {
                                        string revStateLabel = DEItemRevision2.GetRevStateLabel(Convert.ToChar(view2[columnName].ToString().Trim()));
                                        if (num2 == 0)
                                        {
                                            item.Text = revStateLabel;
                                        }
                                        else
                                        {
                                            item.SubItems.Add(revStateLabel);
                                        }
                                    }
                                    else if (attribute.Name == "M_STATE")
                                    {
                                        string str5 = view2[columnName].ToString().Trim();
                                        string text = "无状态";
                                        switch (str5)
                                        {
                                        case "I":
                                            text = "检入";
                                            break;

                                        case "O":
                                            text = "检出";
                                            break;

                                        case "A":
                                            text = "废弃";
                                            break;

                                        case "R":
                                            text = "定版";
                                            break;

                                        case "N":
                                            text = "无状态";
                                            break;
                                        }
                                        if (num2 == 0)
                                        {
                                            item.Text = text;
                                        }
                                        else
                                        {
                                            item.SubItems.Add(text);
                                        }
                                    }
                                    else if (attribute.DataType2 == PLMDataType.Guid)
                                    {
                                        string str7 = "";
                                        if (((view2[columnName] != null) && !view2.Row.IsNull(columnName)) && (((attribute.SpecialType2 == PLMSpecialType.OrganizationType) || (attribute.SpecialType2 == PLMSpecialType.RoleType)) || (attribute.SpecialType2 == PLMSpecialType.UserType)))
                                        {
                                            str7 = PrincipalRepository.GetPrincipalName(new Guid((byte[])view2[columnName]));
                                        }
                                        if (num2 == 0)
                                        {
                                            item.Text = str7;
                                        }
                                        else
                                        {
                                            item.SubItems.Add(str7);
                                        }
                                    }
                                    else
                                    {
                                        string str8 = Convert.ToString(view2[columnName]);
                                        if (attribute.DataType2 == PLMDataType.DateTime)
                                        {
                                            if ((view2[columnName] != null) && !view2.Row.IsNull(columnName))
                                            {
                                                DEMetaAttribute exAttributeByOid = ModelContext.GetExAttributeByOid(this.clsName, attribute.Oid);
                                                string          format           = "yyyy年MM月dd日 HH:mm:ss";
                                                if (((exAttributeByOid != null) && (exAttributeByOid.GetEditorSetup().format != null)) && (exAttributeByOid.GetEditorSetup().format.Length > 0))
                                                {
                                                    format = exAttributeByOid.GetEditorSetup().format.Replace("Y", "y").Replace("D", "d").Replace("S", "s");
                                                }
                                                str8 = Convert.ToDateTime(view2[columnName]).ToString(format);
                                            }
                                            else
                                            {
                                                str8 = "";
                                            }
                                        }
                                        if (num2 == 0)
                                        {
                                            item.Text = str8;
                                        }
                                        else
                                        {
                                            item.SubItems.Add(str8);
                                        }
                                    }
                                }
                                else if (num2 == 0)
                                {
                                    item.Text = view2[columnName].ToString().Trim();
                                }
                                else
                                {
                                    item.SubItems.Add(view2[columnName].ToString().Trim());
                                }
                                item.Tag = view2;
                                num2++;
                                break;
                            }
                        }
                    }
                    this.lvw.Items.Add(item);
                    num++;
                }
            }
        }
コード例 #21
0
ファイル: PropertyPanel.cs プロジェクト: funtomi/MyNewCode
        public void UpdateUI(DEBusinessItem item, DEMetaClassEx meta, Guid uOid, bool readOnly)
        {
            this.Item = item;
            if (meta != null)
            {
                this.meta = meta;
            }
            this.uOid = uOid;
            this.Text = "编辑对象" + item.Master.Id;
            int y      = 20;
            int x      = 20;
            int num3   = 150;
            int num4   = 50;
            int height = 30;
            int width  = 100;
            int num7   = 150;

            this.pnlProperty.Controls.Clear();
            foreach (DEMetaAttribute attribute in this.meta.Attributes)
            {
                if (attribute.IsViewable)
                {
                    Label label = new Label {
                        Location = new Point(x, y + 5),
                        Size     = new Size(width, height),
                        Text     = attribute.Label + ":"
                    };
                    TextBox  box   = null;
                    ResCombo combo = null;
                    if (!readOnly)
                    {
                        if (attribute.LinkedResClass != Guid.Empty)
                        {
                            combo = new ResCombo(ModelContext.MetaModel.GetClass(attribute.LinkedResClass).Name, attribute);
                        }
                        else
                        {
                            box = new TextBox();
                        }
                    }
                    else
                    {
                        box = new TextBox();
                    }
                    if (!attribute.IsEditable || (PLGrantPerm.CanDoClassAttribute(ClientData.LogonUser.Oid, item.Master.ClassName, attribute.Name, item) == 1))
                    {
                        if (box != null)
                        {
                            box.ReadOnly = true;
                        }
                        else if (combo != null)
                        {
                            combo.readOnly = true;
                        }
                    }
                    if (readOnly)
                    {
                        if (box != null)
                        {
                            box.ReadOnly = true;
                        }
                        else if (combo != null)
                        {
                            combo.readOnly = true;
                        }
                    }
                    if (box != null)
                    {
                        box.Location = new Point(num3, y);
                        box.Size     = new Size(num7, height);
                        box.Tag      = attribute;
                    }
                    else if (combo != null)
                    {
                        combo.Location = new Point(num3, y);
                        combo.Size     = new Size(num7, height);
                        combo.Tag      = attribute;
                    }
                    object attrValue = this.Item.Iteration.GetAttrValue(attribute.Name);
                    if (box != null)
                    {
                        if (attrValue is Guid)
                        {
                            box.Text = PrincipalRepository.GetPrincipalName((Guid)attrValue);
                        }
                        else
                        {
                            box.Text = PSConvert.Attribute2String(attrValue, attribute);
                        }
                    }
                    else if (combo != null)
                    {
                        if ((attribute.LinkType == 0) && (attribute.DataType == 8))
                        {
                            if (attrValue == null)
                            {
                                combo.ResValue = "";
                            }
                            else
                            {
                                combo.ResValue = combo.GetResourceID(new Guid((byte[])attrValue), ModelContext.MetaModel.GetClass(attribute.LinkedResClass).Name);
                            }
                        }
                        else
                        {
                            combo.ResValue = PSConvert.Attribute2String(attrValue, attribute);
                        }
                    }
                    this.pnlProperty.Controls.Add(label);
                    if (box != null)
                    {
                        this.pnlProperty.Controls.Add(box);
                    }
                    else if (combo != null)
                    {
                        this.pnlProperty.Controls.Add(combo);
                    }
                    y += num4;
                }
            }
        }