Esempio n. 1
0
        public ActionResult ElencoUtenti()
        {
            Utenti utenti = new Utenti();
            utenti.Add(new Utente { Nome = "Pamela", Cognome = "Sanchini" });
            utenti.Add(new Utente { Nome = "Onorio", Cognome = "Pompizii" });

            return View(utenti);
        }
Esempio n. 2
0
        protected string GetUtenteRuolo(DocsPaWR.ItemReportPregressi report)
        {
            string result = string.Empty;

            if (!string.IsNullOrEmpty(report.idUtente))
            {
                DocsPaWR.Utente utente = null;
                if (this.Utenti == null)
                {
                    this.Utenti = new Dictionary <string, DocsPaWR.Utente>();
                }

                if (Utenti.ContainsKey(report.idUtente))
                {
                    utente = Utenti[report.idUtente];
                }
                else
                {
                    utente = UserManager.GetUtenteByIdPeople(report.idUtente);
                    Utenti.Add(report.idUtente, utente);
                }

                if (utente != null)
                {
                    result = utente.nome + " " + utente.cognome;
                }
            }

            if (!string.IsNullOrEmpty(report.idRuolo))
            {
                if (this.Ruoli == null)
                {
                    this.Ruoli = new Dictionary <string, DocsPaWR.Ruolo>();
                }
                DocsPaWR.Ruolo ruolo = null;

                if (Ruoli.ContainsKey(report.idRuolo))
                {
                    ruolo = Ruoli[report.idRuolo];
                }
                else
                {
                    ruolo = UserManager.getRuoloByIdGruppo(report.idRuolo, this.Page);
                    Ruoli.Add(report.idRuolo, ruolo);
                }

                if (ruolo != null)
                {
                    result = result + " (" + ruolo.descrizione + ")";
                }
            }

            return(result);
        }
Esempio n. 3
0
        public void AggiungiUtente()
        {
            Console.WriteLine("Inserisci nome utente");
            var nome = Console.ReadLine();

            Console.WriteLine("Inserisci cognome utente");
            var cognome = Console.ReadLine();

            Console.WriteLine("Inserisci telefono utente");
            var telefono = Console.ReadLine();

            Console.WriteLine("Inserisci email utente");
            var email = Console.ReadLine();

            Console.WriteLine("Inserisci pass utente");
            var pass   = Console.ReadLine();
            var utente = new Utente(nome, cognome, telefono, email, pass);

            Utenti.Add(utente);
        }
Esempio n. 4
0
        /*  static void GetGroups(PrincipalContext ctx)
         * {
         *
         *
         *    GroupPrincipal qbeGroup = new GroupPrincipal(ctx);
         *    PrincipalSearcher srch = new PrincipalSearcher(qbeGroup);
         *
         *    // find all matches
         *    foreach (var found in srch.FindAll())
         *    {
         *        // do whatever here - "found" is of type "Principal" - it could be user, group, computer.....
         *        //       Console.WriteLine(found.Name);
         *        // found.StructuralObjectClass
         *        if (!found.DistinguishedName.ToString().Contains("CN=Builtin"))
         *        {
         *            Gruppi.Add(found.SamAccountName);
         *        }
         *
         *    }
         * }
         */


        static void GetUsers(PrincipalContext ctx)
        {
            string pathNameDomain = "LDAP://" + sDomain + "/" + distinguishedName.ToString();

            var direcotyEntry     = new DirectoryEntry(pathNameDomain, username, password);
            var directorySearcher = new DirectorySearcher(direcotyEntry)
            {
                Filter = "(|(|(|(msExchRecipientTypeDetails=1)(msExchRecipientTypeDetails=4))(msExchRecipientTypeDetails=2))(msExchRecipientTypeDetails=8))"
            };

            directorySearcher.PropertiesToLoad.Add("msExchRecipientTypeDetails");
            directorySearcher.PropertiesToLoad.Add("distinguishedname");
            directorySearcher.PropertiesToLoad.Add("mail");
            directorySearcher.PropertiesToLoad.Add("objectSid");
            directorySearcher.PropertiesToLoad.Add("DisplayName");
            directorySearcher.PropertiesToLoad.Add("SamAccountName");
            directorySearcher.PropertiesToLoad.Add("msExchRecipientDisplayType");
            directorySearcher.SizeLimit = 2000;
            directorySearcher.PageSize  = 2000;
            var searchResults = directorySearcher.FindAll();


            foreach (SearchResult searchResult in searchResults)
            {
                var row = new UserInfo();
                row.Distinguishedname = searchResult.Properties["distinguishedname"][0].ToString();

                var temp = searchResult.Properties["mail"];
                if (temp.Count != 0)
                {
                    row.Mail = temp[0].ToString();
                }


                var sidBytes = searchResult.Properties["objectSid"][0] as byte[];
                var sid      = new SecurityIdentifier(sidBytes, 0).ToString();
                row.ObjectSID = sid.ToString();

                var temp2 = searchResult.Properties["DisplayName"];
                if (temp2.Count != 0)
                {
                    row.DisplayName = searchResult.Properties["DisplayName"][0].ToString();
                }

                var temp3 = searchResult.Properties["msExchRecipientTypeDetails"];
                if (temp3.Count != 0)
                {
                    row.msExchRecipientTypeDetails = searchResult.Properties["msExchRecipientTypeDetails"][0].ToString();
                }
                row.SamAccountName = searchResult.Properties["samaccountname"][0].ToString();


                var temp4 = searchResult.Properties["msExchRecipientDisplayType"];
                if (temp4.Count != 0)
                {
                    row.RecipientType = searchResult.Properties["msExchRecipientDisplayType"][0].ToString();
                }

                Utenti.Add(row);
            }
            Trace.WriteLine(DateTime.Now.ToString("yyyyMMddHHmmss") + "::INIT::found " + Utenti.Count + " Users");
            direcotyEntry.Dispose();
            directorySearcher.Dispose();
            searchResults.Dispose();


            // "Identity","Name","DisplayName","SamAccountName","RecipientType","RecipientTypeDetails","WindowsEmailAddress"

            string stringFilePath = "ExportData\\mailboxes.csv";

            System.IO.TextWriter writer = File.CreateText(stringFilePath);

            string OutputLine = "Identity,Name,DisplayName,SamAccountName,RecipientType,RecipientTypeDetails,WindowsEmailAddress";

            writer.WriteLine(OutputLine);

            foreach (var row in Utenti)
            {
                writer.WriteLine("," + row.DisplayName + "," + row.DisplayName + "," + row.SamAccountName + "," + row.RecipientType + "," + row.RecipientTypeDetails + "," + row.Mail);
            }
            writer.Close();
        }