public static FullyQualifiedADName GetADNameFromDescriptor(string descriptor) { FullyQualifiedADName adName = new FullyQualifiedADName(); StringBuilder domainName = new StringBuilder(); int domainNamePartCount = 0; string[] fields = descriptor.Split(",".ToCharArray()); foreach (string field in fields) { string[] nameValue = field.Split("=".ToCharArray()); if (nameValue[0] == "CN") { adName.Name = nameValue[1]; } else if (nameValue[0] == "DC") { if (domainNamePartCount > 0) { domainName.Append("."); } domainName.Append(nameValue[1]); domainNamePartCount++; } } if (string.IsNullOrWhiteSpace(adName.Name) || domainNamePartCount != 4) { Planner.Instance.WriteToEventLog("User Information string not recognized: " + descriptor); } adName.DomainName = domainName.ToString(); return(adName); }
private void InitializeDirectReports() { if (UserEntry != null) { PropertyValueCollection reports = UserEntry.Properties["directReports"]; foreach (string report in reports) { FullyQualifiedADName adName = GetADNameFromDescriptor(report); UserInformation uiReport = new UserInformation(); if (!uiReport.InitializeWithFullName(adName.Name, adName.DomainName)) { Planner.Instance.WriteToEventLog("Updating team members: fullname did not resolve: " + adName.Name); } DirectReports.Add(uiReport); } } }