Get Current User's Role in Application_PreRequestHandlerExecute() function - asp.net-mvc

I am working on MVC 4 web application. I need to know if there is a way to find the role of the currently logged in user in the Application_PreRequestHandlerExecute() function (present in Global.asax).
I used to use Roles.IsUserInRole("Admin") function to know if the user belongs to Admin role or not, but for some reason this function and User.IsInRole("Admin") function do not seam to work.
The above mentioned two functions are giving the following error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I tried searching for a solution but failed to find one. If someone has any idea and can guide me on this.
Thanks.

Related

SQL Server connection established during design, but not during runtime

I have created an Amazon RDS DB instance. I can connect to it and perform operations with SSMS. I can also bind to it using Entity Framework DB-first and generate my model. However, when I run my app, using the same connection string that was generated in the data access project, I get a "the network path was not found" error while trying to establish a connection to the DB.
Let me be clear: the db exists, the right ports are open, and the connection string is correct. I am the only one connecting to the database and the status is "available".
So what's going on? Has anyone experienced something like this?
Let me also further mention that I have already checked the usual things like internet connectivity, firewall rules, state of the database, etc.
well it started working all of a sudden. So I guess this problem will only pop up again in production or something.

TF246017: team foundation server could not connect to the database

I am facing a problem with logging into TFS. I get the following error:
Exception Message: TF246017: Team Foundation Server could not connect
to the database. Verify that the server that is hosting the database
is operational, and that network problems are not blocking
communication with the server. (type SoapException)SoapException
Details:
Hi the below steps worked for me.
Select Application Tier in the TFS Administration Console.
In the Application Tier Summary which contains the Service Account details.
Click Reapply Account.
I know this is old, but here was my situation:
We have 11 collections on our instance, 2 were failing with this error, showing me it wasn't an access / connection issue. Checking Event Viewer (as #Andy Li-MSFT suggests) showed it was
A timeout occurred while waiting for memory resources to execute the query in resource pool 'default' (2). Rerun the query.
Checking task manager showed the culprit - elastic search was using well over 2GB of memory. I killed the service, the collections applied the patch quickly without issue.
Looks like I need to ask our server admins to give us a bit more memory....
Please check below thing to narrow down the issue:
Make sure you are the member of the Administration Console Users.
Otherwise you cannot access the Admin Console.
Make sure the SQL Server is stated and available, and the network
connectivity is OK.
Check the Service Account, make sure the Service Account has been added in
SQL Server.
You can also refer to the solution in below link to fix the issue:
https://www.ganshani.com/alm/tfs/visual%20studio/solved-tf246017-team-foundation-server-could-not-connect-to-the-database/
If above solution can not resolve the problem, please check the Event log. The Windows Event Log is a good candidate where to look for the potential cause.
For me I've solved the issue by changing the recovery mode Simple -> Full in the database.
Please refer to: https://www.mssqltips.com/sqlservertutorial/3/sql-server-full-recovery-model/

kCFErrorDomainCFNetwork Code 2 - kCFHostErrorUnknown

I am having an error when trying to change an iFrame's location.
WebSocket network error: The operation cannot be completed. (kCFErrorDomainCFNetwork Code 2)
I am having this exception on Safari Mobile (iPad). This error does not occur on Safari Desktop.
kCFErrorDomainCFNetwork Code 2 is kCFHostErrorUnknown. But, what does this mean and how can I fix this?
According to the documentation,
kCFHostErrorUnknown
An unknown error occurred (a name server failure, for example). For additional information, you can query the kCFGetAddrInfoFailureKey key to obtain the value returned by getaddrinfo and look up the value in /usr/include/netdb.h.
Where can I query the kCFGetAddrInfoFailureKey? Also, I don't think I can look up netdb.h.
I found the issue. Since I am using IP Address to access the server. The WebSocket server should also be IP Address.

Oracle error occurred, but error message could not be retrieved from Oracle

There is a delphi application in which I am trying to connect to Oracle database Using provider MSDAORA.1 but problem is coming in connecting. Oracle error message which is coming is "Oracle error occurred, but error message could not be retrieved from Oracle"
I am able to connect to database with Oracle10g client.
Connection String: Provider=MSDAORA.1;
User ID=murat;
Password = murat;
Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp) (HOST= INGPSP)(PORT=1521))(CONNECT_DATA=(SID=INGPSP)));
Persist Security Info=False;
Please provide your expert opinion what can be the reason of this?
The service name seems to be lacking in your address.
Set a tnsnames.ora file, and use the entry as data source instead of the data_source parameter you set. Follow the steps available on the faq.
Or use use connection strings like '//host[:port]/[service_name]' for your data source: //INGPSP:1521/ServiceName
For Oracle, both Microsoft and Oracle OleDB providers are known to have issue with BLOBs. If you can, use another mean of connection.
What I see that is strange is that your HOST and SID are the same. The HOST is the name of the machine on your network and the SID is the database instance on that machine. I created the following ConnectionString for the PRD3 database on machine DB19 (there are multiple databases on DB19) on our network. I was able to connect to the database successfully with real User ID and Password.
Provider=MSDAORA.1;
Password=123456;
User ID=abc;
Data Source="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db19)(PORT=1521))(CONNECT_DATA=(SID=prd3)))";
Persist Security Info=True
Normally the Data Source I use is the database name as defined in TNSNAMES.ORA. It is a lot less to type (fewer potential errors) and can be changed to another database without recompiling the program (such as switching between a development database and production database).

Connect to Sun LDAP with ADO

I want to connect (and get user's group) to a Sun LDAP server with a Delphi program.
I think ADSI works only with Microsoft LDAP. I try it with ADO, but I can't connect.
Can someone show some code how I would do this?
I think this code will fit the bill.
There is more to ADSI than just LDAP, and from my experience it is easier to use LDAP client to connect to ActiveDirectory than the other way around - which is what you are trying to do, unfortunatly.
To get you started, here is a fail safe way to authenticate a user.
Establish a connection with your LDAP server with your service account. If possible, use the LDAP protocol over SSL, LDAPS
Search for the username (wich is the CN=jdoe part) to get the full DN (distinguished name)
If you have duplicate result, stop here with an error
Bind to the LDAP with the DN and password you are trying to validate. Make shure you are using the same validation method on both side.
If it binds, the password is valid.
Close the connection you just established
Depending on your needs, either hold on to the connection you made a step 1 or tear it down, too.

Resources