protected internal override string GenerateRDNPrefix(ADObjectFactory <ADObject> factory, ADParameterSet cmdletParameters, NewADObjectParameterSet dynamicParameters) { ADSessionInfo sessionInfo = this.GetSessionInfo(); ADSchemaUtil aDSchemaUtil = new ADSchemaUtil(sessionInfo); string rDNPrefix = aDSchemaUtil.GetRDNPrefix(dynamicParameters.Type); if (rDNPrefix == null) { rDNPrefix = factory.RDNPrefix; } return(rDNPrefix); }
protected internal virtual string GenerateNewRDN(F factory, string newName, ADObject target) { string empty = string.Empty; if (target.Contains("objectClass")) { ADSessionInfo sessionInfo = this.GetSessionInfo(); ADSchemaUtil aDSchemaUtil = new ADSchemaUtil(sessionInfo); empty = aDSchemaUtil.GetRDNPrefix(target["objectClass"].Value as string); } if (!string.IsNullOrEmpty(newName)) { newName = Utils.EscapeDNComponent(newName); } if (!string.IsNullOrEmpty(empty)) { empty = string.Concat(empty, "=", newName); } return(empty); }
protected internal override string GenerateObjectClass(ADUserFactory <ADUser> factory, ADParameterSet cmdletParameters, NewADUserParameterSet dynamicParameters) { string item = null; if (dynamicParameters != null && dynamicParameters.Contains("Type")) { item = (string)dynamicParameters["Type"]; if (item != null) { ADSchemaUtil aDSchemaUtil = new ADSchemaUtil(this.GetCmdletSessionInfo().ADSessionInfo); HashSet <string> userSubClasses = aDSchemaUtil.GetUserSubClasses(); if (!userSubClasses.Contains(item)) { throw new ArgumentException(string.Format(StringResources.UnsupportedObjectClass, item), "Type"); } } } if (item == null) { item = factory.StructuralObjectClass; } return(item); }
private static bool VerifyAppliesToClasses(ADObject directoryObj, StringBuilder errorBuffer, CmdletSessionInfo cmdletSessionInfo) { bool flag = false; if (directoryObj.Contains("msDS-ClaimTypeAppliesToClass")) { ADSchemaUtil aDSchemaUtil = new ADSchemaUtil(cmdletSessionInfo.ADSessionInfo); string[] valueList = directoryObj["msDS-ClaimTypeAppliesToClass"].ValueList as string[]; string[] strArrays = valueList; for (int i = 0; i < (int)strArrays.Length; i++) { string str = strArrays[i]; HashSet <string> allParentClassesForSchemaClassDN = aDSchemaUtil.GetAllParentClassesForSchemaClassDN(str); allParentClassesForSchemaClassDN.IntersectWith(ADClaimTypeFactory <T> .ValidAppliesToClasses); if (allParentClassesForSchemaClassDN.Count == 0) { flag = true; object[] objArray = new object[1]; objArray[0] = str; errorBuffer.AppendLine(string.Format(CultureInfo.CurrentCulture, StringResources.SPCTInvalidAppliesToClassWarning, objArray)); } } if (directoryObj.Contains("msDS-ClaimAttributeSource")) { string value = directoryObj["msDS-ClaimAttributeSource"].Value as string; ADSchemaObjectFactory <ADSchemaObject> aDSchemaObjectFactory = new ADSchemaObjectFactory <ADSchemaObject>(); aDSchemaObjectFactory.SetCmdletSessionInfo(cmdletSessionInfo); ADSchemaObject aDSchemaObject = new ADSchemaObject(); aDSchemaObject.Identity = value; string[] strArrays1 = new string[1]; strArrays1[0] = "lDAPDisplayName"; ADObject extendedObjectFromIdentity = aDSchemaObjectFactory.GetExtendedObjectFromIdentity(aDSchemaObject, cmdletSessionInfo.ADRootDSE.SchemaNamingContext, strArrays1); if (extendedObjectFromIdentity.Contains("lDAPDisplayName")) { string value1 = extendedObjectFromIdentity["lDAPDisplayName"].Value as string; string[] strArrays2 = valueList; for (int j = 0; j < (int)strArrays2.Length; j++) { string str1 = strArrays2[j]; HashSet <string> attributeListForSchemaClassDN = aDSchemaUtil.GetAttributeListForSchemaClassDN(str1); if (!attributeListForSchemaClassDN.Contains(value1)) { flag = true; object[] objArray1 = new object[2]; objArray1[0] = str1; objArray1[1] = value1; errorBuffer.AppendLine(string.Format(CultureInfo.CurrentCulture, StringResources.SPCTAttributeNotFoundInSchemaClass, objArray1)); } } } else { flag = true; object[] objArray2 = new object[1]; objArray2[0] = value; errorBuffer.AppendLine(string.Format(CultureInfo.CurrentCulture, StringResources.SPCTSourceAttributeLdapDisplayNameError, objArray2)); } } } return(!flag); }