/// <summary> /// Determines if this object class is a special object class. /// Special object classes include the predefined ones, such as /// <see cref="ObjectClass.ACCOUNT"/> and <see cref="ObjectClass.GROUP"/>. /// </summary> /// <param name="oclass">the object class to test</param> /// <returns>true iff the object class is special</returns> /// <exception cref="NullReferenceException">if the object class parameter is null</exception> public static bool IsSpecial(ObjectClass oclass) { String name = oclass.GetObjectClassValue(); return IsSpecialName(name); }
public ICollection<String> GetDefaultAttributesToGet(ObjectClass oclass) { ICollection<string> attributesToGet = new HashSet<String>(); ActiveDirectoryConnector connector = new ActiveDirectoryConnector(); connector.Init(ConfigHelper.GetConfiguration()); Schema schema = connector.Schema(); ObjectClassInfo ocInfo = schema.FindObjectClassInfo(oclass.GetObjectClassValue()); Assert.IsNotNull(ocInfo); foreach (ConnectorAttributeInfo caInfo in ocInfo.ConnectorAttributeInfos) { if (caInfo.IsReturnedByDefault) { attributesToGet.Add(caInfo.Name); } } return attributesToGet; }
/// <summary> /// Returns the AD ObjectClass associated with a particular /// Connector ObjectClass /// </summary> /// <param name="oclass"></param> /// <returns></returns> internal String GetADObjectClass(ObjectClass oclass) { if (oclass.Equals(ObjectClass.ACCOUNT)) { return _configuration.ObjectClass; } else if (ActiveDirectoryConnector.groupObjectClass.Equals(oclass)) { return "Group"; } else if (ActiveDirectoryConnector.ouObjectClass.Equals(oclass)) { return "organizationalUnit"; } else { // It's not something I know about, so I'll consult the AD schema. // if it's there, fine, but if not throw an exception. //first check to see if we have seen it before. String objectClassName = oclass.GetObjectClassValue(); if(_knownObjectClasses.Contains(objectClassName)) { return objectClassName; } // if we havent seen it before, consult AD's schema ActiveDirectorySchema ADSchema = GetADSchema(); ActiveDirectorySchemaClass ADSchemaClass = null; try { ADSchemaClass = ADSchema.FindClass(objectClassName); _knownObjectClasses.Add(objectClassName); return objectClassName; } catch (ActiveDirectoryObjectNotFoundException exception) { String msg = _configuration.ConnectorMessages.Format( "ex_ObjectClassInvalidForConnector", "ObjectClass \'{0}\' is not valid for this connector", objectClassName); throw new ConnectorException(msg); } } }
internal ConnectorObject CreateConnectorObject(ExchangeConnector connector, PSObject psobject, ObjectClass objectClass) { ConnectorObjectBuilder builder = new ConnectorObjectBuilder(); string guid = (string)psobject.Properties["guid"].Value.ToString(); string name = (string)psobject.Properties["name"].Value; builder.SetUid(new Uid(guid)); builder.SetName(new Name(name)); ObjectClassInfo ocinfo = connector.GetSchema().FindObjectClassInfo(objectClass.GetObjectClassValue()); IDictionary<string,PSPropertyInfo> properties = psobject.Properties.ToDictionary(psinfo => psinfo.Name); LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Building connector object with UID = {0} and Name = {1}", guid, name); foreach (ConnectorAttributeInfo cai in ocinfo.ConnectorAttributeInfos) { if (cai.IsReadable && properties.ContainsKey(cai.Name)) { object value = properties[cai.Name].Value; LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, " - attribute {0} = {1}", cai.Name, value); if (value is PSObject) { var ps = value as PSObject; value = ps.BaseObject; LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, " - attribute {0} UNWRAPPED = {1} ({2})", cai.Name, value, value.GetType()); } builder.AddAttribute(cai.Name, CommonUtils.ConvertToSupportedForm(cai, value)); } } return builder.Build(); }