Archive for the ‘Windows’ Category

LDAP provider with remote login (VBscript)

23 March 2013 1 comment

Lately I needed to perform some Active Directory code using the LDAP provider that had to connect to a computer in another domain. This is possible, but took some investigation.

Error checking and variable definitions are missing, just a code sample.

Using these values:

strUser = "contoso\testuser"
strPass = "********"
strComp = "" '* the remote domain controller
strAccount = "testfind"

First Part, getting AD info.

Connect to the remote domain controller and query it for the default naming context. This example could return “DC=CONTOSO,DC=COM” in strTargetDncDomain if a login as the testuser was successful.

Const ADS_SERVER_BIND = &h0200

Set objDSO = GetObject("LDAP:")
Set objRootDse = objDSO.OpenDSObject("LDAP:\\" & strComp & "\RootDSE" , _
  strUser, strPass, _
strTargetDncDomain = objRootDse.Get("defaultNamingContext")

To summarise, instead of just using GetObject(), you now need to use the OpenDSObject method on an LDAP provider object and provide some extra parameters to the method.

Second Part, searching AD info.

Search the AD for a specific object. If the object is found, you can use it, similar to how the RootDSE object is obtained, just with a different AD path instead of “RootDSE” e.g. the value of strDnFound. The strTargetDncDomain defined in the first example is used here.

This is almost the same as the case without logging on, just a few extra properties needed.

strBase    = "<" & "LDAP:\\" & strComp & "\" & strTargetDncDomain & ">;"
strAttrs = "distinguishedName,sAMAccountName;"
strScope = "subtree"
strFilter = "(&(objectCategory=person)(objectClass=user)(sAMAccountName=" & strAccount & "));"

strQuery = strBase & strFilter & strAttrs & strScope

Set oConnection = CreateObject("ADODB.Connection")
oConnection.Provider = "ADsDSOObject"
oConnection.Properties("Encrypt Password") = True
oConnection.Open "Active Directory Provider", strUser, strPass

Set oCommand = CreateObject("ADODB.Command")
oCommand.ActiveConnection = oConnection
oCommand.Properties("Page Size") = 100
oCommand.Properties("Timeout") = 30
oCommand.Properties("Cache Results") = False

oCommand.CommandText = strQuery
Set objRS = oCommand.Execute
Do While Not objRS.EOF
  strDnFound = objRS.Fields("distinguishedName")

Here, like in the first example, only a few extra parameters are needed to do a remote login to a specific server.


Linux Samba with CIFS and Windows Home Server

7 October 2012 Leave a comment

Last year I experimented with a borrowed NAS  and wanted to use it as a backup for my windows home server. At home most of my computers run linux and I wanted to map those shares automatic on my main desktop. Not wanting to re-invent a wheel again, I did a google search and found this:

So I needed to put the following lines in  /etc/fstab, or for testing, something similar after the sudo mount command

my Nas (all on the same line):
//nas/data /media/nas cifs credentials=/root/.naslogin, rw,iocharset=utf8,dir_mode=0777,file_mode=0777 0 0

My Homeserver (all on the same line):
//whs/ebooks /media/whs/ebooks cifs credentials=/root/.whslogin, rw,iocharset=utf8,dir_mode=0777,file_mode=0777 0 0

This worked for my NAS but not for my windows home server.  Mounting the share from the home server  failed . It just trow an error: “mount error(5): Input/output error“, that pointed to the right solution. NOT!

After some searching, I found the reason. I was not using the netbios name for the windows server, but an alias.

What happened.

Mounting the share failed because windows refused the connection. The internal netbios name of my home server did not match the name in the mount command.

Remember that for windows, the computer name is also the netbios name, and the home server is running Windows Home Server (i.e. Windows 2003). I decided to have a dns name for my home server different than the internal computer name, so there was a mismatch.

Once I knew the cause, the solution to this was easy. Just use the same computer name as the computer thinks it has, and not something else 🙂 even through that other name resolves to the same computer. After adding the netbios name of my home server to the hosts file on linux and using the netbios name in the mount command, it worked.

sudo mount -t cifs //roheve/ebooks /media/whs/ebooks -o credentials=/root/.whslogin,iocharset=utf8,dir_mode=0777,file_mode=0777,nounix

And now it ‘just works’.

PS: I need to remember these to (copy_n_paste is easy)

sudo mount -t cifs //sw-hy1.testlab.local/c$/data /media/testlab/hy1 -o credentials=/root/.testlab,iocharset=utf8,dir_mode=0777,file_mode=0777,nounix

sudo mount -t cifs //sw-hy2.testlab.local/data /media/testlab/hy2 -o credentials=/root/.testlab,iocharset=utf8,dir_mode=0777,file_mode=0777,nounix

Categories: Linux, Windows Tags: , , ,

Dual boot Windows7 and Ubuntu on my Netbook

17 July 2011 Leave a comment

Added Linux to my Netbook that came with Windows pre-installed.

As I use mostly Linux at home, but occasionaly need Windows (e.g my plugwise gadgets came with a windows only software). As I do not want to install ‘home’ software on my Windows 7  ‘work’  laptop, I decided to keep this Windows on a small partition, as I paid for it’s license anyway, and could be usefull.

This Windows 7 is a ‘starter edition’, i.e. cheap, but did not encounter a real limitation. Well I can not ‘RDP’  into it, but that is also not possible with the Windows 7 home versions.

Well, next step was to get Ubuntu Linux on it (I use that version on my ‘main’ home desktop computer). To not re-invent the wheel while making it dual-boot, I looked for and found a nice tutorial for this. Must say it works well that way.

The basic steps involved are:

  • Shrink the windows partition to a workable minimum to make room for the linux partitions.
  • Install EasyBCD in windows to configure the windows bootmanager
  • Install ubuntu, make sure to put ‘grub’ in the linux bootpartition, not the disk bootsector
  • Add ubuntu to the windows bootmanager (and make it the default)

Job done…

I made this entry, so I can find the tutorial again, just in case I need it.



A restriction in Excel 2010 Starter I bumbed into was that there is no option to connect to an SQL or Access database. Well this is ‘advanced’  usage, so logical it is missing.

Categories: Linux, Windows