Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have my custom webpart, which have access to database. I need to configure data source, catalog, username and password, which allows webpart a access database. I don't want that users can see, what is account name or password. What is best way manage user rights in SharePoint?

I have thinking couple ways, but I cannot tell are these ideas good and whether there are better ways manage this?

Idea1: I save all neasesery information to list and I somehow hide it from users? (HOW?) Webpart reads this list information and access a database.

Idea2: Hardcode connection string to webpart. However maintenance will suffer.

Idea3: Webpart settings and connection string, but then all users must set it and it will not work.

share|improve this question

migrated from stackoverflow.com Jan 27 at 14:32

This question came from our site for professional and enthusiast programmers.

3 Answers 3

no need for any of those!

you just need to add it to web.config

http://msdn.microsoft.com/en-us/library/jj653752(v=vs.110).aspx

and

http://msdn.microsoft.com/en-us/library/ms228094(v=vs.85).aspx

somthing on the lines of:

<appSettings>
<add key="SQLConnectionString" value="server=http://mysite.mysite.com;database=myDatabaseservername;uid=MyUserName;password=MyPassword;" />
</appSettings>

MyUserName and MyPassword would need to be changed to a user account that has access to the sql server...

server=http://mysite.mysite.com (You sql server name) and database=myDatabaseservername (your sql database name) need to be changed to the correct values! all can be found when logging in into sql server!

share|improve this answer

Create a custom tool part for you password using a password text box as the control.

Its just a case of subclassing the ToolPart control then adding the password textbox in the CreateChildControls() method

This link goes into the full detail

share|improve this answer

Modifying the web.config should be your last choice, in case of SharePoint. Especially, if there are other possibilities, like the following:

Store the connection string, user name and password in the the property bag of the SPSite.RootWeb or SPWebApplication or SPFarm (depends on how granular you want to be with these settings). Data in the property bag is completely hidden from the end user. It can be set and retrieved only by code or by powershell - for both you need access on the SharePoint Server.

It's worth to check out this blog post too, if you have wondered about the difference between SPWeb.Properties and SPWeb.AllProperties.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.