473,661 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get user company

(Sorry my bad English)
Hi,
I want to get User company not User name. How to do it?

Regards,
Son

Nov 16 '05 #1
2 2252
Hi Son,

I believe you mean User Group or User Role. All that stuff is in System.Security .Principal

You can get a WindowsIdentity from the user running the code with

WindowsIdentity wi = WindowsIdentity .GetCurrent();

Then you can get all roles for that identity by using Type.InvokeMemb er, cleverly demonstrated by Joe Kaplan and translated to C# by Chris Taylor
http://dotnetjunkies.com/WebLog/chri...2/25/7945.aspx

public static string[] GetWindowsIdent ityRoles( WindowsIdentity identity )
{
object result = typeof(WindowsI dentity).Invoke Member( "_GetRoles" ,
BindingFlags.St atic | BindingFlags.In vokeMethod | BindingFlags.No nPublic,
null, identity, new object[]{identity.Token }, null );
return (string[])result;
}

You can also test if a user is a member of a specific role like BUILTIN\Adminis trators

WindowsPrincipa l wp = new WindowsPrincipa l(wi); // wi = WindowsIdentity .GetCurrent()

if(wp.IsInRole( "BUILTIN\\Admin istrators"))
// someone with administrator rights

--
Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2
Hi Morten,
Thanks for your time!

Regards,
Son

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1386
by: Eje | last post by:
I am developing a webapplication for a company holding stocks for a number of customer companies. The customers can order parts via this new appliction. My application is linked to each of the customers' home pages. I want each user to 'believe' he still is in his company's pages by changing logo and i.e. backcolor depending on company. A person from company A will see his company's logo and colors and a person from company B will...
6
1454
by: Stan | last post by:
We have several intranet ASP.NET web sites. Users log on to the sites by using form authentication and custom security (user names and passwords are stored in the database). If a user logs on to the first site and from within this site is redirected to another one, we would like to pass its security information along, so the user doesn't need to log on again. I am thinking of making a gateway page that will have two url parameters,...
0
1083
by: Justice Gray | last post by:
The background to my problem: I have constructed a small web application. Each page of that web application contains a small user control I made, that has three sections: 1) imgCompany (of type ImageButton) My company's logo 2) imgCustomer (of type ImageButton) The customer company's logo. The ImageUrl property changes according to the
3
1737
by: Amir Eshterayeh | last post by:
Dear Friends Would you please give me your professional idea about this asp.net problem. I need different virtual directory for different customer with their names like these: www.oursite.com/Jack www.oursite.com/Sue www.oursite.com/Tom
1
1218
by: Paul Say | last post by:
Here is the seniaro, I have a user control consisting of a list of 3 Companies. e.g 1 - Company A 2 - Company B 3 - Company C - These are read from a data base and may increase in the future. What I wan to be able to do is have the control rember its state. with regards to the following
2
251
by: Jack | last post by:
Hi, If I just say have a user control which contains a datalist that displays information about different companies. The datalist contains an image for the company logo and some text describing the company. Now this is fine if each company template is the same BUT what if I want each company to be able to have there own template e.g. one having one logo and another have three. Now I could do this by creating one user control for each...
5
2336
by: teddysnips | last post by:
I have to write an application to do some data cleansing. It's a Contact database, but over a number of years there are multiple companies which are all essentially the same entity. For each company there are also multiple contacts, some of which may be congruent. It's a very simple app. with only two forms. The first form shows two lists. The left-hand list is a Single-Select showing all the companies. The user chooses one company -...
3
1442
by: JJ | last post by:
Whats the best way to do this?: Users from different companies need to log into a web site. I want to add the users company name, address etc to their profile. However I want the company details to be stored separately (i.e. in a separate table in the database) as more than one person could be from the same company. I though that if I set up the company table and add the companyID to the user profile that might do the job?
15
2278
by: bb nicole | last post by:
The company profile showed blank after user login and click the company profile button. Supposed the company profile should not be blank and will show the company information which call from database. I use the session in login page. Thus, in the begining of companyProfile's coding, i put session_start();. What is the problem of my php code?? Thanks.. <?php ob_start(); session_start(); include_once("database.php"); if($_GET ==...
2
1983
by: parvtb | last post by:
Thanks for your patience to read the entire post to understand my confusion I have the user-defined class "tools": class tools{ public: tools( ......) {} friend bool operator< (const tools& lhs, const tools& rhs) { cout<<"lhs="<<lhs.company<<"."<<lhs.name <<" rhs="<<rhs.company<<"."<<rhs.name<<endl;
0
8432
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7364
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.