SPUtility Class
The SPUtility class provides tools for converting date and time formats, for getting information from user names, for securing access to sites, and for various other tasks in managing a deployment of Microsoft Windows SharePoint Services.
System.Object
Microsoft.SharePoint.Utilities.SPUtility
Public Fields
The following table shows the fields of the SPUtility class and a brief description of each.
Name | Description |
---|---|
MaxLeafNameLength | Indicates the maximum number of characters that can be used in the name of a file or folder. |
Public Methods
The following table shows the methods of the SPUtility class and a brief description of each.
Name | Description |
---|---|
AlternateServerUrlFromHttpRequestUrl | Returns the outgoing URL for the alternate request URL represented by the specified URI. |
ChangeAccountPassword | Changes an account password for the specified SharePoint site. |
CreateDateTimeFromSqlString | Converts the specified SQL string (in yyyymmdd hh:mm:ss format) to DateTime format. |
CreateISO8601DateTimeFromSystemDateTime | Converts a system DateTime value to ISO8601 DateTime format (yyyy-mm-ddThh:mm:ssZ). |
CreateSystemDateTimeFromXmlDataDateTimeFormat | Converts the XML DateTime format to system DateTime format (yyyy-mm-dd hh:mm:ss). |
EnsureAuthentication | Determines whether the current user is an authenticated user of the specified site and, if not, requests a user name and password and then opens the Error page for an access denied exception so that the user must request access to the site or list from the owner. |
EnsureSiteAdminAccess | Determines whether the current user is a site administrator on the specified site and, if not, requests a user name and password and then opens the Error page for an access denied exception so that the user must request access to the site or list from the owner. |
FormatDate | Converts the specified date and time value to an SPDateFormat format. |
GetAcceptHeaderExtensions | Returns the set of accept headers associated with file extensions defined in the configuration file for a site. |
GetCalendarYearMax | Returns the maximum year that can be represented in calendars. |
GetCalendarYearMin | Returns the minimum year that can be represented in calendars. |
GetExampleDateFormat | Returns an example of the format used for dates within the specified site. |
GetFullNameFromLogin(Microsoft.SharePoint.Administration.SPGlobalAdmin, String) | Returns the display name of the user on a server or server farm with the specified user name. |
GetFullNameFromLogin(Microsoft.SharePoint.SPSite, String) | Returns the display name of the site user with the specified user name. |
GetFullNameFromLoginEx | Returns the display name of a user on the specified site based on the user name and a Boolean value indicating whether the user object represents a distribution list. |
GetFullUrl | Returns the absolute URL for the specified server-relative URL. |
GetGenericSetupPath | Returns the full local path for the specified subdirectory. |
GetHtmlTranslateUrlFromExt | Returns the URL of a back-end converter program used to handle a request when the client computer does not have the Microsoft Office application installed. |
GetIdentifierFromEmail | Returns the ID of the site user based on the specified e-mail address. |
GetLoginNameFromEmail | Returns the domain user account of the user based on the specified site collection and e-mail address. |
GetNTFullNameandEmailfromLogin(Microsoft.SharePoint.Administration.SPGlobalAdmin, String, String, String) | Returns the display name and e-mail address used in Windows NT for a specified user on the server or server farm. |
GetNTFullNameandEmailfromLogin(Microsoft.SharePoint.SPWeb, String, String, String) | Returns the display name and e-mail address used in Windows NT for a user on the specified site. |
GetRequestAccess | Returns a Boolean value that indicates whether the current user has access to the specified site or list. |
GetServerNow | Returns the current date and time in Coordinated Universal Time (UTC) used on the database server for the specified site. |
GregorianISOToIntlISODate | Converts the specified date from the International Organization for Standardization (ISO) Gregorian format to the ISO International format. |
GuessLoginNameFromEmail | Returns the domain user account of the user based on the specified e-mail address. |
IsEmailServerSet | Returns a Boolean value that specifies whether an e-mail server has been set for the site. |
IsLoginValid(Microsoft.SharePoint.Administration.SPGlobalAdmin, String) | Uses the specified global administration object to determine whether the specified user name is valid. |
IsLoginValid(Microsoft.SharePoint.Administration.SPGlobalAdmin, String, Boolean) | Uses the specified global administration object to determine whether the specified user name is valid and whether it corresponds to a user account. |
IsLoginValid(Microsoft.SharePoint.SPSite, String) | Uses the specified site collection to determine whether the specified user name is valid. |
IsUplevelBrowser | Returns a Boolean value that indicates whether the version of the browser is later than Microsoft Internet Explorer 5.0 or Netscape Navigator 6.0, based on the HTTP context of the request. |
MapToIcon | Returns the name of the image file for the icon that is used to represent the specified file. |
MapWebURLToVirtualServerURL | Returns the absolute URL for the virtual server that contains the specified site. |
ParseDate | Creates a System.DateTime object from the specified strings containing date and time values. |
SendAccessDeniedHeader | Requests a user name and password and then opens the Error page for an access denied exception so that the user must request access to the site or list from the owner. |
SendEmail | Sends the e-mail message to the specified address. |
SendRequestAccessToOwner | Sends a request for access in an e-mail message to the owner of the list or site. |
TimeDeltaAsString | Returns the difference between two specified DateTime values as a string. |
ValidateDatabaseConnectionString | Validates the connection string for the content database or the configuration database. |
ValidateFormDigest | Validates the form digest control used in the current request. |
Thread Safety
Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread safe.
Remarks
Because all the methods of the SPUtility class are static, you do not need to instantiate the class to use them.
Example
The following code example iterates through the collection of document discussions for a document library and uses the SendEmail method of the SPUtility class to send e-mail notification to a specified address if the total number of comments made about a document is greater than 20.
This example requires using directives (Imports in Visual Basic) for both the Microsoft.SharePoint and Microsoft.SharePoint.Utilities namespaces.
Requirements
Namespace: Microsoft.SharePoint.Utilities
Platforms: Microsoft Windows Server 2003
Assembly: Windows SharePoint Services (in Microsoft.SharePoint.dll)
Security: Code Access Security