473,395 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

C# permissions

Daxthecon
Expand|Select|Wrap|Line Numbers
  1. if (username == "watson_c")
  2.             {
  3.                 name.Visible = false;
  4.                 changename.Visible = true;
  5.                 changename.Value = "criteria here";
  6.             }
The problem here is that I don't want to hardcode usernames... It's ridiculous to do if you are in a large company with poeple changing frequently and an app for almost everything then you are changing stuff in your code when it coulde be the Net admins issue with changing who is manager or whatever in the AD. So to negait this practice I want to query the ad and check to see if the person is a manager and make it so they can see the changename field. I don't know how to google search for this. I've tried "AD username permissions" and all that jazz it just comes up with permissions to ad queries and not queriest to get permissions. Anyone got a better source even a MSDN or a code sample would be great.
Sep 16 '08 #1
4 1699
PRR
750 Expert 512MB
Are you using a database? How about using Generic Identity and Generic Principal or maybe windows identity and principal? Can you explain further?
Sep 17 '08 #2
Ok so right now I have an array catching a few properties from the LDAP(Active Directory). These properties are funneled into one variable and the if statement then tells the variable which property it wants for it's particular needs. What I need is to find anyone with that is a manager(which means they have direct reports) and puts them in to this statement. Basically then this statement just decides based on is the person a manager.
Sep 17 '08 #3
PRR
750 Expert 512MB
Ok so right now I have an array catching a few properties from the LDAP(Active Directory). These properties are funneled into one variable and the if statement then tells the variable which property it wants for it's particular needs. What I need is to find anyone with that is a manager(which means they have direct reports) and puts them in to this statement. Basically then this statement just decides based on is the person a manager.
Can you post some code?
Sep 17 '08 #4
Sure here is the code as it sits right now and I'll explain why it was done that way and it was meant for in short summary.
Expand|Select|Wrap|Line Numbers
  1. DirectoryEntry entry = new DirectoryEntry("LDAP://OU=DAXCON,DC=hq,DC=local");
  2.  
  3.             DirectorySearcher search = new DirectorySearcher(entry);
  4.  
  5.             search.Filter = "(samaccountname=" + username + ")";
  6.             search.PropertiesToLoad.Add("name");
  7.             search.PropertiesToLoad.Add("distinguishedName");
  8.             search.PropertiesToLoad.Add("mail");
  9.             search.PropertiesToLoad.Contains("manager");
  10.  
  11.             foreach (SearchResult result in search.FindAll())
  12.             {
  13.                 name.Text = result.Properties["name"][0].ToString();
  14.                 email.Text = result.Properties["mail"][0].ToString();
  15.  
  16.                 string[] pieces = result.Properties["distinguishedName"][0].ToString().Split(',');
  17.  
  18.                 if (pieces[1] == "OU=11")
  19.                 {
  20.                     department.Text = "Bartonville";
  21.                     depthead.Text = "Manager Name";
  22.                     phone1.Text = "###";
  23.                     phone2.Text = "###";
  24.                     phone3.Text = "####";
  25.                 }
  26.                 if (pieces[1] == "OU=12")
  27.                 {
  28.                     department.Text = "Nebraska";
  29.                     depthead.Text = "Manager Name";
  30.                     phone1.Text = "###";
  31.                     phone2.Text = "###";
  32.                     phone3.Text = "####";
  33.                 }
  34.                 if (pieces[1] == "OU=13")
  35.                 {
  36.                     department.Text = "Sterling";
  37.                     depthead.Text = "Manager Name";
  38.                     phone1.Text = "###";
  39.                     phone2.Text = "###";
  40.                     phone3.Text = "####";
  41.                 }
  42.                 if (pieces[1] == "OU=20")
  43.                 {
  44.                     department.Text = "Southfield";
  45.                     depthead.Text = "Manager Name";
  46.                     phone1.Text = "###";
  47.                     phone2.Text = "###";
  48.                     phone3.Text = "####";
  49.                 }
  50.                 if (pieces[1] == "OU=30")
  51.                 {
  52.                     department.Text = "St. Louis";
  53.                     depthead.Text = "Manager Name";
  54.                     phone1.Text = "###";
  55.                     phone2.Text = "###";
  56.                     phone3.Text = "####";
  57.                 }
  58.                 if (pieces[1] == "OU=DAXCON")
  59.                 {
  60.                     department.Text = "No Office Listed";
  61.                     depthead.Text = "None";
  62.                     phone1.Text = "###";
  63.                     phone2.Text = "###";
  64.                     phone3.Text = "####";
  65.                 }
  66.                 if (pieces[1] == "CN=manager")
  67.             {
  68.                 name.Visible = false;
  69.                 changename.Visible = true;
  70.                 changename.Value = ("distinguishedName");
  71.             }
  72.  
  73.             }
  74.             entry.Close();
  75.         }
  76.         item13.Attributes.Add("onchange", "total()");
  77.         item14.Attributes.Add("onchange", "total()");
  78.  
  79.  
  80.  
  81.     }
What the code does as of right now is hides a combo box full of the names of poeple in the company. If you are not authorized to see this box it shows your distinguishedName and then locks it to be uneditable. The code also finds your manager and phone number the cheating way which is something I am going to have to fix as well. But as of right now the array is shooting to a variable and that variable is being used mulitple times and can be used for any of the particular attributes that are loaded in the search filter.

What I need to do is mak the last if statement go to the manager section and see if they are the manager of someone. If they are then they get permission to see the box. If not then they don't see the box. Simple and complicated. I realized the search would take place in the pieces array but I still am new to the AD and LDAP and don't know how to search it effectively.

NOTE: Most of this code is from the former programmer as I am filling in his place.
Sep 17 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Kim Lots | last post by:
Hi Sorry to disturb you again but i really like to know what's the NTFS folder permissions on a "virtual directory" folder for a public webserver iis 5.x running ASP 3.0 with an Access DB on a...
1
by: Brad H McCollum | last post by:
I'm writing an application using VB 6.0 as the front-end GUI, and the MSDE version of SQL Server as the back-end (it's a program for a really small # of users --- less then 3-4). I'm trying to...
6
by: !!! Klutzo !!! | last post by:
I give permissions for ASPNET on a top level subdirectory. A windows program copies a file into the subdirectory, however, my web service cannot access the file because it does not have...
2
by: Jozef | last post by:
Hello, Is there a way to change table permissions in VB Code? I can't seem to find much that's concise in the help file. Here's the situation; I have a table in the "data" portion of a split...
7
by: none | last post by:
Hello: I had a nice php application running on my server here at home, and I uploaded it to a shared public type server and it started to break all over the place. It turns out that some...
13
by: MLH | last post by:
Invalid qualifier error displays at compile time on this A97 example from Permissions Property HELP. What's wrong with the strContainerName assignment line? (6th line) Sub...
0
by: Curt K | last post by:
We run some web services (IIS 5 and IIS 6) that communicate to a COM out of process server, which in turn communicates to another out of process COM server (long story). We have had lots of...
8
by: jporter188 | last post by:
Hello, I am working on a project to manipulate XML files. All of the files, the code, and the output are on network drives. When I run my program I get an exception (see below). I tried giving...
3
by: palepimp | last post by:
Hello all, I have searched far and wide for a solution to my issue. In short, here is the problem: 1. 3 PC's enter data into an Access 2003 database (PC's are running Vista w/ Office 2007...
6
by: DotNetNewbie | last post by:
Hello, in my web application, I have to create permissions for each user. So what I am doing is that for each role (using sqlmembership in .net) I am creating a column in the database to hold a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.