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(); }
private async System.Threading.Tasks.Task buildBasicInfoSegment(DirectoryEntry result) { //Fills in basic user info displayName.Text = result.Properties["displayName"][0].ToString(); //lblbasicInfoOfficePDS if (result.Properties.Contains("aauStaffID")) { string empID = result.Properties["aauStaffID"].Value.ToString(); var pds = new PDSConnector(empID); lblbasicInfoDepartmentPDS.Text = pds.Department; lblbasicInfoOfficePDS.Text = pds.OfficeAddress; } //Other fileds var attrToDisplay = "userPrincipalName, aauUserStatus, aauStaffID, aauStudentID, aauUserClassification, telephoneNumber, lastLogon"; var attrDisplayName = "UserName, UserStatus, StaffID, StudentID, UserClassification, Telephone, LastLogon (approx.)"; var attrArry = attrToDisplay.Replace(" ", "").Split(','); var dispArry = attrDisplayName.Split(','); string[] dateFields = { "lastLogon", "badPasswordTime" }; var sb = new StringBuilder(); for (int i = 0; i < attrArry.Length; i++) { string k = attrArry[i]; sb.Append("<tr>"); sb.Append(String.Format("<td>{0}</td>", dispArry[i].Trim())); if (result.Properties.Contains(k)) { if (dateFields.Contains(k)) { sb.Append(String.Format("<td>{0}</td>", convertADTimeToDateTime(result.Properties[k].Value))); } else { string v = result.Properties[k].Value.ToString(); sb.Append(String.Format("<td>{0}</td>", v)); } } else { sb.Append("<td></td>"); } sb.Append("</tr>"); } //Email var helper = new HTMLTableHelper(2); var proxyAddressesAD = result.Properties["proxyAddresses"]; var proxyAddresses = proxyAddressesAD.Cast<string>().ToArray<string>(); string email = ""; foreach (string s in proxyAddresses) { if (s.StartsWith("SMTP:", StringComparison.CurrentCultureIgnoreCase)){ var tmp2 = s.ToLower().Replace("smtp:", ""); email += string.Format("<a href=\"mailto:{0}\">{0}</a><br/>", tmp2); } } sb.Append(helper.printRow(new string[] { "E-mails", email })); string attName = "msDS-UserPasswordExpiryTimeComputed,msDS-User-Account-Control-Computed"; result.RefreshCache(attName.Split(',')); const int UF_LOCKOUT = 0x0010; int userFlags = (int)result.Properties["msDS-User-Account-Control-Computed"].Value; //basicInfoPasswordExpired.Text = "False"; if ((userFlags & UF_LOCKOUT) == UF_LOCKOUT) { // basicInfoPasswordExpired.Text = "True"; } // Never expire = 9223372036854775807 DateTime? expireDate = convertADTimeToDateTime(result.Properties["msDS-UserPasswordExpiryTimeComputed"].Value); if (expireDate == null) { basicInfoPasswordExpireDate.Text = "Never"; } else { basicInfoPasswordExpireDate.Text = expireDate.ToString(); } labelBasicInfoTable.Text = sb.ToString(); var admdb = new ADMdbConnector(); String upn = (string)result.Properties["userPrincipalName"][0]; string firstName = (string)result.Properties["givenName"][0]; string lastName = (string)result.Properties["sn"][0]; var tmp = upn.Split('@'); var domain = tmp[1].Split('.')[0]; //Make lookup in ADMdb var watch = System.Diagnostics.Stopwatch.StartNew(); basicInfoAdmDBExpireDate.Text = await admdb.loadUserExpiredate(domain, tmp[0], firstName, lastName); watch.Stop(); System.Diagnostics.Debug.WriteLine("ADMdb Lookup took: " + watch.ElapsedMilliseconds); //Has roaming labelBasicInfoRomaing.Text = "false"; if (result.Properties.Contains("profilepath")) { labelBasicInfoRomaing.Text = "true"; } //Password Expire date "PasswordExpirationDate" }
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(); }
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(); }
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(); }