Beispiel #1
0
        private void buildComputerInformation(DirectoryEntry result)
        {

            string upn = (string)result.Properties["userPrincipalName"][0];
            string[] upnsplit = upn.Split('@');
            string domain = upnsplit[1].Split('.')[0];

            string userName = String.Format("{0}\\\\{1}", domain, upnsplit[0]);

            var helper = new HTMLTableHelper(2);

            var sb = new StringBuilder();
            sb.Append("<h4>Links til computerinfo kan være til maskiner i et forkert domæne, da info omkring computer domæne ikke er tilgængelig i denne søgning</h4>");
            sb.Append(helper.printStart());
            sb.Append(helper.printRow(new string[] { "Computername", "AAU Fjernsupport" }, true));

            var ms = new ManagementScope("\\\\srv-cm12-p01.srv.aau.dk\\ROOT\\SMS\\site_AA1");
            var wqlq = new WqlObjectQuery("SELECT * FROM SMS_UserMachineRelationship WHERE UniqueUserName = \"" + userName + "\"");
            var searcher = new ManagementObjectSearcher(ms, wqlq);

            foreach (ManagementObject o in searcher.Get())
            {
                var machinename = o.Properties["ResourceName"].Value.ToString();
                var name = "<a href=\"/computerInfo.aspx?computername=" + machinename + "\">" + machinename + "</a><br />";
                var fjernsupport = "<a href=\"https://support.its.aau.dk/api/client_script?type=rep&operation=generate&action=start_pinned_client_session&client.hostname="+machinename + "\">Start</a>";
                sb.Append(helper.printRow(new string[]{name, fjernsupport}));
            }
            sb.Append(helper.printEnd());
            divComputerInformation.Text = sb.ToString();

        }
Beispiel #2
0
        protected void buildExchangeLabel(String[] groupsList, bool isTransitiv)
        {
            var sb = new StringBuilder();

            if (!isTransitiv)
            {
                sb.Append("<h3>NB: Listen viser kun direkte medlemsskaber, kunne ikke finde fuld liste på denne Domain Controller eller domæne</h3>");
            }
            
            var helper = new HTMLTableHelper(4);

            sb.Append(helper.printStart());
            sb.Append(helper.printRow(new string[] { "Type", "Domain", "Name", "Access" }, true));

            foreach (string group in groupsList)
            {
                if (group.StartsWith("CN=MBX_"))
                {
                    var adpathsplit = group.Split(',');
                    var nameSplit = adpathsplit[0].Split('_');

                    if (nameSplit.Length == 5)
                    {
                        //A normal exchange resource group

                        var type = nameSplit[2];
                        var domain = nameSplit[1];
                        var name = String.Format("<a href=\"/GroupsInfo.aspx?grouppath={0}\">{1}</a><br/>", HttpUtility.UrlEncode("LDAP://" + group), nameSplit[3]);
                        var access = nameSplit[4];
                        sb.Append(helper.printRow(new string[] { type, domain, name, access }));


                    } //XXX: if Length == 4 this a all resources group
                    else if (nameSplit.Length == 4)
                    {

                        var type = nameSplit[2];
                        var domain = nameSplit[1];
                        var name = String.Format("<a href=\"/GroupsInfo.aspx?grouppath={0}\">{1}</a><br/>", HttpUtility.UrlEncode("LDAP://" + group), nameSplit[2]);
                        var access = nameSplit[3];
                        sb.Append(helper.printRow(new string[] { domain, type, name, access }));
                    }
                }
            }
            sb.Append(helper.printEnd());

            lblexchange.Text = sb.ToString();
        }
Beispiel #3
0
        protected void buildFilesharessegmentLabel(String[] groupsList, bool isTransitiv)
        {
            StringBuilder sb = new StringBuilder();

            if (!isTransitiv)
            {
                sb.Append("<h3>NB: Listen viser kun direkte medlemsskaber, kunne ikke finde fuld liste på denne Domain Controller eller domæne</h3>");
            }

            var helper = new HTMLTableHelper(4);
            sb.Append(helper.printStart());
            sb.Append(helper.printRow(new string[] { "Type", "Domain", "Name", "Access" }, true));

            foreach (string group in groupsList)
            {

                var split = group.Split(',');
                var oupath = split.Where<string>(s => s.StartsWith("OU=")).ToArray<string>();
                int count = oupath.Count();

                if (count == 3 && oupath[count - 1].Equals("OU=Groups") && oupath[count - 2].Equals("OU=Resource Access"))
                {
                    //This is a group access group
                    var groupname = split[0].Replace("CN=", "");
                    var groupNameSplit = groupname.Split('_');

                    var type = groupNameSplit[2];
                    if (type.Equals("generic"))
                    {
                        type = "fileshares";
                    }
                    else
                    {
                        type = "department";
                    }
                    var domain = groupNameSplit[1];

                    //XXX: Can do this with array copy and a join simpler 
                    string nameString = null;
                    for (int i = 3; i < groupNameSplit.Length - 1; i++)
                    {
                        if (nameString == null)
                        {
                            nameString = groupNameSplit[i];
                        }
                        else { 
                            nameString = nameString + "_" + groupNameSplit[i];
                        }
                    }
                    
                    var name = String.Format("<a href=\"/GroupsInfo.aspx?grouppath={0}\">{1}</a><br/>", HttpUtility.UrlEncode("LDAP://" + group), nameString);
                    var access = groupNameSplit[groupNameSplit.Length-1];

                    sb.Append(helper.printRow(new string[] { type, domain, name, access }));


                }
            }
            sb.Append(helper.printEnd());

            filesharessegmentLabel.Text = sb.ToString();

        }
Beispiel #4
0
        protected void buildgroupssegmentLabel(String[] groupsList)
        {
            StringBuilder sb = new StringBuilder();

            var helper = new HTMLTableHelper(2);
            sb.Append(helper.printStart());
            sb.Append(helper.printRow(new string[]{"Domain", "Name"}, true));

            Array.Sort(groupsList);
            var skiped = new List<string>();

            foreach (string adpath in groupsList)
            {
                if (!(adpath.StartsWith("CN=MBX_") || adpath.StartsWith("CN=ACL_"))) //if not fileshare or mailbox
                {
                    var split = adpath.Split(',');
                    var groupname = split[0].Replace("CN=", "");
                    var domain = split.Where<string>(s => s.StartsWith("DC=")).ToArray<string>()[0].Replace("DC=", "");
                    var name = String.Format("<a href=\"/GroupsInfo.aspx?grouppath={0}\">{1}</a><br/>", HttpUtility.UrlEncode("LDAP://" + adpath), groupname);

                    sb.Append(helper.printRow(new string[] { domain, name }));
                }
                else
                {
                    skiped.Add(adpath);
                }
            }

            foreach (string adpath in skiped)
            {
                
                    var split = adpath.Split(',');
                    var groupname = split[0].Replace("CN=", "");
                    var domain = split.Where<string>(s => s.StartsWith("DC=")).ToArray<string>()[0].Replace("DC=", "");
                    var name = String.Format("<a href=\"/GroupsInfo.aspx?grouppath={0}\">{1}</a><br/>", HttpUtility.UrlEncode("LDAP://" + adpath), groupname);

                    sb.Append(helper.printRow(new string[] { domain, name }));
                
            }

            sb.Append(helper.printEnd());
            groupssegmentLabel.Text = sb.ToString();

        }