Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Programmaticly Changing the e-mail address used for Access Requests

  Asked By: Sonny    Date: Jan 20    Category: Sharepoint    Views: 4153

I was wondering if anyone had any bright ideas on how to
programmaticly change the e-mail address that a site collection uses
when it sends out requests for access.

I know that this field gets populated with the Primary Owner's e-mail
address but when you change the primary owner, the value doesn't
change. Furthermore, I don't see anything in the object model or the
web services that allow me to modify this value.

I've found where this is stored in the content database (Webs table,
RequestAccessEmail column) but I'd prefer to not modify the database
directly if I don't have to.

Any bright ideas from anyone would be apreciated.

Share: 

 

8 Answers Found

 
Answer #1    Answered By: Monte Cooley     Answered On: Jan 20

I just changed my setting at _layouts/1033/setrqacc.aspx?type=web for the
access requests. I got there by going to the Top-Level Admin page and
selecting Manage access  Requests under Users and Permissions. Is that what
you were referring to? I have not done it programmatically yet but it is
probably in an XML file maybe?

 
Answer #2    Answered By: Guadalupe Bullock     Answered On: Jan 20

No, I can perform the operation fine thru the web UI...What I am looking for is a way to programmaticly change  that value without human intervention.

 
Answer #3    Answered By: Nathanial Mcclure     Answered On: Jan 20

Its definitely in the database, its in the Webs table  in the RequestAccessEmail column.

 
Answer #4    Answered By: Matt Prince     Answered On: Jan 20

I think I found  it. Instead of directly hitting the tables, I always try to use the SharePoint object  Model. In the SP Object Model there is an owner  property of the SPSite class:
The Owner property of the SPSite class gets or sets the owner of the site  collection.
public Microsoft.SharePoint.SPUser Owner {get; set;}
Property Value
A Microsoft.SharePoint.SPUser object that represents the owner.
So this will return a SPUser instance that represents the Owner. In the SPUser class there is a property for email. So if you first get the Site Owner by using:
string url = "http://Your Server_Name/sites/Your Site_Name/default.aspx";
SPSite mySite = new SPSite(url);
SPUser siteOwner = mySite.Owner;
siteOwner.Email="theownersemail";

You could then use the class called SPUtility that has a method called SendRequestAccessTo Owner. Below is the entry from the SDK documentation. Let us know if this works for you.

public static bool SendRequestAccessToOwner(
Microsoft.SharePoint.SPWeb web,
Microsoft.SharePoint.SPObjectType objType,
string objID,
string txtMessageBody
);
Parameters
web A Microsoft.SharePoint.SPWeb object that represents the site.
objType A Microsoft.SharePoint.SPObjectType value that specifies whether the object is a list or a site.
objID The ID of the list or site.
txtMessageBody A string that contains the message to convey to the owner.

Return Value
true if the e-mail  is sent to the owner; otherwise, false.

 
Answer #5    Answered By: Brooks Bond     Answered On: Jan 20

But this method Sends an e-mail  to the already registered e-mail address  for the site  or list. What I want to do is change  that e-mail address so that in the future when people stumble onto a url they can't access, the e-mail will go to the right person.

 
Answer #6    Answered By: Gregg Wilkinson     Answered On: Jan 20

That was in the second part of my post. In the first part I showed how to change  the owner  email. Isn't that what you wanted? Here is the code again:
In the SP object  Model there is an Owner property of the SPSite class:
The Owner property of the SPSite class gets or sets the owner of the site  collection.
public Microsoft.SharePoint.SPUser Owner {get; set;}
Property Value
A Microsoft.SharePoint.SPUser object that represents the owner.
So this will return a SPUser instance that represents the Owner. In the SPUser class there is a property for email. So if you first get the Site Owner by using:
string url = "http://Your Server_Name/sites/Your Site_Name/default.aspx";
SPSite mySite = new SPSite(url);
SPUser siteOwner = mySite.Owner;
siteOwner.Email="theownersemail";

This should allow you to change where the email goes. The second part of the post was just infromational if you wanted to prorgammatically send the email. Is that clear?

 
Answer #7    Answered By: Darrel Sexton     Answered On: Jan 20

Its been my experience that changing  the site  Collection's Prmary Owner's email doesn't change  the Manage Request Access e-mail  address. Granted, I have been changing the Primary owner  to a whole different person than just changing the e-mail address  of the current owner. With that said, changing the owner to a different person is what my Use Case is.

 
Answer #8    Answered By: Tory Sellers     Answered On: Jan 20

I'm pleased to inform everyone that I found  a solution to my problem. The SPPermissionCollection object  associated with a Site Collection's RootWeb can be used to set this property. The property is called RequestAccessEmail.

Its a real roundabout way to set this property, but at least it is possible to accomplish this.

 




Tagged: