private static ClassifyResult ClassifyLink(Uri uri, WindowsIdentity authenticatedUser) { if (uri == null) { throw new ArgumentNullException("uri"); } if (!uri.IsAbsoluteUri) { throw new ArgumentException("uri"); } ClassifyResult classifyResult; try { if (uri.IsUnc) { classifyResult = LinkClassifier.ClassifyUncLink(uri, authenticatedUser); } else { if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps) { classifyResult = LinkClassifier.ClassifySharepointLink(uri, authenticatedUser); if (classifyResult.Error == ClassificationError.None) { goto IL_9A; } try { if (LinkClassifier.CheckIfLinkExists(uri, authenticatedUser)) { classifyResult = new ClassifyResult(null, uri, UriFlags.Other); } else { classifyResult = new ClassifyResult(uri, ClassificationError.ObjectNotFound); } goto IL_9A; } catch (WebException) { goto IL_9A; } catch (NotSupportedException) { goto IL_9A; } } classifyResult = new ClassifyResult(uri, ClassificationError.UriTypeNotSupported); } IL_9A :; } catch (AuthenticationException) { classifyResult = new ClassifyResult(uri, ClassificationError.AccessDenied); } return(classifyResult); }
private static Uri GetSiteAddress(Uri uri, out ClassifyResult result) { result = null; Uri result2; using (Webs webs = new Webs(uri.GetLeftPart(UriPartial.Authority))) { webs.Credentials = CredentialCache.DefaultCredentials; try { Uri uri2 = new Uri(webs.WebUrlFromPageUrl(uri.ToString())); if (string.Compare(uri2.ToString().TrimEnd(new char[] { '/', '\\' }), uri.ToString().TrimEnd(new char[] { '/', '\\' }), StringComparison.OrdinalIgnoreCase) == 0) { result = new ClassifyResult(new SharepointSiteId(uri2.OriginalString, UriFlags.Sharepoint), uri, UriFlags.Sharepoint); } else if (uri.Segments.Length == uri2.Segments.Length + 1 && string.Compare(uri.Segments[uri.Segments.Length - 1], "default.aspx", StringComparison.OrdinalIgnoreCase) == 0) { if (LinkClassifier.CheckIfLinkExists(uri, null)) { result = new ClassifyResult(new SharepointSiteId(uri2.OriginalString, UriFlags.Sharepoint), uri, UriFlags.Sharepoint); } else { result = new ClassifyResult(null, uri, UriFlags.Other); } } return(uri2); } catch (SoapException) { result = new ClassifyResult(uri, ClassificationError.ObjectNotFound); } catch (WebException) { throw; } catch (InvalidOperationException) { result = new ClassifyResult(null, uri, UriFlags.Other); } catch (NotSupportedException) { result = new ClassifyResult(null, ClassificationError.ConnectionFailed); } result2 = null; } return(result2); }
private static SharepointList GetListSpecifics(Uri uri, SharepointSession session, out ClassifyResult result) { SharepointList sharepointList = null; int num = 0; result = null; foreach (object[] array in session.GetView(ListBaseType.Any, new PropertyDefinition[] { DocumentLibrarySchema.Id }).GetRows(int.MaxValue)) { SharepointList sharepointList2 = SharepointList.Read(session, (ObjectId)array[0]); Uri uri2 = sharepointList2.Uri; int num2 = 0; int num3 = session.Uri.Segments.Length; while (num3 < uri2.Segments.Length && num3 < uri.Segments.Length && string.Compare(uri.Segments[num3].TrimEnd(new char[] { '/', '\\' }), uri2.Segments[num3].TrimEnd(new char[] { '/', '\\' }), StringComparison.CurrentCultureIgnoreCase) == 0) { num3++; num2++; } if (num2 > num) { sharepointList = sharepointList2; num = num2; } else if (num2 == num) { sharepointList = null; } } if (sharepointList == null) { result = new ClassifyResult(uri, ClassificationError.ObjectNotFound); } else if (sharepointList.ItemType == SharepointItemType.List) { result = new ClassifyResult(sharepointList.Id, uri, UriFlags.SharepointList); } else if (!uri.Query.Contains("&RootFolder=") && !uri.Query.Contains("?RootFolder=")) { Uri uri3 = sharepointList.Uri; if (string.Compare(uri.AbsolutePath, uri3.AbsolutePath, StringComparison.OrdinalIgnoreCase) == 0) { result = new ClassifyResult(sharepointList.Id, uri, UriFlags.SharepointDocumentLibrary); } else if (uri.Segments.Length == uri3.Segments.Length) { for (int j = 0; j < uri.Segments.Length - 1; j++) { if (string.Compare(uri3.Segments[j], uri.Segments[j], StringComparison.OrdinalIgnoreCase) != 0) { return(sharepointList); } } if (LinkClassifier.CheckIfLinkExists(uri, null)) { result = new ClassifyResult(sharepointList.Id, uri, UriFlags.SharepointDocumentLibrary); } else { result = new ClassifyResult(uri, ClassificationError.ObjectNotFound); } } } return(sharepointList); }