I have never worked on authorization in Vb.Net before. So the below question might sound stupid for advanced programmers. Please apologize.
I am trying to get the list of the Active Directory Groups of the logged in user. I was told that Roles.GetRolesForUser() is the best way to achieve it. I wrote the below code in my web.config.
<roleManager
enabled="true"
cacheRolesInCookie="true" >
</roleManager>
and added the below code in code behind.
Dim userRoles As String() = Roles.GetRolesForUser()
I see the userRoles.length is 0. I verified the user is having more than one active directory groups associated with. Either this is because the configuration which I set in web.config is wrong or this is not the way to get all the active directory groups for this user. Any suggestions are appreciated.
Either I am too stupid to understand the Roles.GetRolesForUser() or configuring it is really hard.:)
I solved this problem using IsInRole() method. I knew the possible ADGroups which would access my app and made that as a configurable item in web.config. Then used String.Split() and then manually checked with HttpContext.Current.User.IsInRole() to verify the user can access the app.
Related
Ok, I have a workflow built in SharePoint 2010, built in SharePoint Designer. It is set up to begin whenever a new item is created. The library is also set up to create new items based on email attachments. So the goal is for users to email the attachments to the library and the workflow takes over.
The workflow only works for me. The other people attempting to use it are listed as Full Control in the permissions. They are using the correct email address, and the library is creating the new items based on the attachments. The problem is that the workflow keeps saying error occurred.
The error says something about some columns needing different types of data, but when I email to the library it goes off without a hitch.
I am completely stumped as to what could be different about them sending the email instead of me.
Sorry I got kind of long winded, and thanks in advance for any help.
The system account is not allowed to initiate workflow on its own. There is a powershell that you need to run to enable system account to run workflow. Also try impersonation in workflow.
Here found it.
stsadm.exe –o setproperty –propertyname declarativeworkflowautostartonemailenabled –propertyvalue yes
Not sure what was wrong with it, but I just deleted it then rebuilt it and now it works. Don't think I did anything different so I'm not sure.
Can anyone link me to a good Selenium-Grid-Extras guide? I have it installed, and need to customize it. Specifically, I need to update the credentials, and reboot settings. When I go to my link: http://XX.XX.XX.XX:3000/user_auto_logon, I can see the settings, but I don't know how to change them. Also, when I open my selenium_grid_extras_config.json I don't see a section that has any of this information to update. Also, even if I did find a section in the selenium_grid_extras_config.json, how would I update the password for the existing username... I'm sure it's not going to be displayed in plain text. Thanks in advance!
From Shawn McCarthy. This solved my problem:
If you want, you can just delete the selenium_grid_extras_config.json file, and rerun the jar file and it will go through the FirstTimeRunConfig again.
You should be able to pass in the username and password to the endpoint as well, http://XX.XX.XX.XX:3000/user_auto_logon?username=YOUR_USER&password=YOUR_PASSWORD
You can check out the /api endpoint to see all the possible endpoints, and the accepted parameters (and which ones are required or not). Usually with no parameters, it does a get current status/value.
Thanks Shawn!
I have used Intellegencia UrlRewriter for a while now.
I used it with VB class that looks up the product Name and gets the relevant ID number to use for the querystring.
It works great.
How can I do the same thing in Umbraco?
I have thought of 1 way:
To use url structure of ~/products/product_name/ (which is really ~/products/product.aspx?id=XX) and add ~/products/* as a reserved folder and basically take this entire page out of Umbraco.
The problem is that my client would like the site structure to be ~/product_name/ (not in a subfolder). My problem is that I don't think I have any way to tell Umbraco not to handle these pages.
Can anyone help me?
You can inform umbraco to ignore paths with the following appSettings key in your web.config:
<appSettings>
....
<add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/product_name/" />
This key is included in the web.config by default so you can search umbracoReservedPaths and you will find it. Simply add your path and umbraco will ignore it. You may also specify individual pages with the umbracoReservedUrls appSetting key.
Of note, you will see that in the /config/ folder there is a UrlRewritting.config for the urlrewritting.net rewritter already integrated into your umbraco install.
I'm writing software in VB .NET (2005) which uses the Windows user information as login credentials - just the username. I've found Environment.UserName which works for the username (as you would expect).
However, I need more information - I need the full name of the user (as shown on the Start Menu). It seems this information is stored... somewhere, as Windows is able to use it for things like permissions on file shares.
I've heard there's calls in user32.dll that can do this, but I'd like a .NET method if it's at all possible. I also have a SID for the user, if that helps at all.
Does anyone know the best way to get this additional information?
It seems the System.DirectoryServices namespace is exactly what I'm looking for.
Always seems that you find the answer right after you ask :)
For future reference:
Dim ent As New DirectoryServices.DirectoryEntry("WinNT://<Domain>/<Username>")
Dim props As DirectoryServices.PropertyCollection = ent.Properties
Debug.Print(props.Item("FullName").Value)
I built a small website and there will be only one admin, so in the admin panel I am asking for a password with a value that I do not retrieve from a database, I just hard coded it in the function in code behind, I know this is wrong though I don't know why.
So is hard coding it in web.config the right thing to do? and how?
As far as it being wrong... the problem is that if you ever need to change it, and it's hardcoded in your codebehind, you need to recompile,republish, re-deploy your website, whereas a change to the web.config can be done without doing this.
You could put it in an AppSetting in the web.config like so.
<appSettings>
<add key="AdminPassword" value="ASDF1234" />
</appSettings>
and use this code to retrieve it
System.Configuration.ConfigurationManager.AppSettings["AdminPassword"].ToString()
Though I'd have a look at this.
https://web.archive.org/web/20211029043331/https://aspnet.4guysfromrolla.com/articles/021506-1.aspx
It covers encrypting sections of your web.config
Nothing wrong with Eoin's suggestion for tiny projects but if your project may someday need more than 1 admin and different types of users roles. I would take the hit and setup ASP membership.
http://msdn.microsoft.com/en-us/library/ms998347.aspx
You can use integrate it into windows or use a database and it's not too hard to setup. Especially if you use the built in config tool in IIS.