Tuesday, September 18, 2007

Creating a new code version in visual sourcesafe

We needed to "branch" a new version of visual sourcesafe, but we couldn't get it working because the "branch" link was always greyed out when we clicked on a file.

Finally figured out that you have to "Share" the file, before you can branch it. Sharing + branching is essentially the same as copying, but do they call it that? Nooooooo. This microsoft page had some help, but it wasn't very clear. Here's how we got it to work.

  1. Right-click the parent directory (the shared files will go in a sub-directory of this directory
  2. Select "Share to ... blahdeblahdeblah ..." on the menu.
  3. A dialog will appear. Navigate to the directory you want to copy.
  4. Click the "Branch after share" checkbox.
  5. Click "Share"
  6. Name your new directory, and click the "Recursive" checkbox (to copy all sub-directories)

Very basic instructions for LDAP

The Accessing Global Address List article at csharpcorner gives very basic instructions on setting up a website with a single page that displays users from Active Directory. It doesn't give any troubleshooting tips, though.

Encrypting connection strings in web.config

Microsoft's Encrypting Configuration Information Using Protected Configuration walkthrough explains how to encrypt connection strings in your web.config file. Looks like you add a section to the connectionstrings tag that handles encryption.

Monday, September 17, 2007

Azman

There is a program called AzMan that seems to help manage roles / users for a website. It's a free microsoft thing. Here is a how-to for setting the thing up . Probably doing a web search for AzMan would shed some light on this, but I can't be bothered with that right now. I just want to blog it here so I don't forget about it, if I need it someday.

Forms Authentication and Web config

This page from microsoft tells how to do forms authentication with LDAP / Active directory through web.config, with no code behind. This would be pretty neat, it if works.

Getting the login name of a logged in user

http://forums.asp.net/t/1045923.aspx
string windowsLogin = Page.User.Identity.Name;
//Normally if the domain is present you get a string like DOMAINNAME\username, remove the domain
int hasDomain = windowsLogin.IndexOf(@"\");
if (hasDomain > 0)
{
windowsLogin = windowsLogin.Remove(0, hasDomain + 1);
} //end if


Check the cache

Apparently, LDAP can sometimes get messed up when windows caches the LDAP information. Somehow. This really doesn't make any sense.

1. Go to the registry : HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ADs\Providers\LDAP\distinguished name of the schema container
2. Here you'll find a string called File which contains the location of the schema. Usually it says : %SystemRoot%\SchCache\[server_name].sch
3. Rename or delete this file.

http://forums.asp.net/t/1011119.aspx

Active directory search won't run on client computer

Active Directory search works fine on dev machine with debugger, and on the web server. It breaks when you try to use the page from another machine.

The forum post says to check "Trust computer for delegation". I don't know what delegation is, so this likely wouldn't fix anything I'm working on, but it's something to try if nothing else works, I suppose.

http://forums.asp.net/t/1062417.aspx
1. I went into Active Directory and opened up the computer account for the web server. I checked the box which says "Trust computer for delegation."
2. I opened up my user account and checked the box "Account is trusted for delegation."

LDAP terms I need to know

Security Context
Understanding security context is very important, according to this faq. Too bad I don't know what it is.
I have found that 90% of the issues with System.DirectoryServices code are related to security and your binding context. If you don't understand your context you are pretty screwed to begin with. Understand what security context your code is executing under!
Forums.ASP.Net LDAP connection FAQs


Identity Impersonation

Checking the "Identity Impersonation" link fixed this guy's problem. Don't know what it is either.
http://forums.asp.net/t/1141117.aspx

Delegation

Checking the "Trust computer for delegation" box fixed this Active Directory problem. http://forums.asp.net/t/1062417.aspx

Search works from a windows application, but not through ASP.NET

If you can connect to Active Directory using a windows app, such as the Softerra browser, but not through ASP.Net, it is often a permissions issue (according to my reading, anyway. I have no actual experiance). It often happens when you are connecting to LDAP annonymously.

To fix this, create a system account that only has read access to active directory. Always pass this username and password when connecting. If you can't do this, these two pages have helpful hints.

LDAP connection FAQ, Forums.ASP.Net, Microsoft's DirectoryServices connection help page. (Most of the problems on these pages can be avoided by connecting with a username and password)