internal static ADObjectSearcher DistinguishedNameIdentityResolver(object identityObject, string searchBase, CmdletSessionInfo cmdletSessionInfo, out bool useSearchFilter) { useSearchFilter = false; if (identityObject != null) { string str = identityObject as string; if (string.IsNullOrEmpty(str) || !ADPathModule.IsValidPath(str, ADPathFormat.X500) || !ADForestPartitionInfo.IsDNUnderPartition(cmdletSessionInfo.ADRootDSE, str, false)) { ADObject aDObject = identityObject as ADObject; if (aDObject == null || string.IsNullOrEmpty(aDObject.DistinguishedName)) { return(null); } else { return(IdentityResolverMethods.BuildDNBaseSearcher(aDObject.DistinguishedName, cmdletSessionInfo)); } } else { return(IdentityResolverMethods.BuildDNBaseSearcher(str, cmdletSessionInfo)); } } else { throw new ArgumentNullException("identityObject"); } }