Quick Active Directory LDAP query variable issue
I have the following:
LDAP://ou=X,dc=X,dc=X;(&(objectCategory=person)(objectClass=user)(sAMAccountName=strCuruser));sAMAccountNam e,altRecipient,mailNickname;subtree
I need strCuruser to be a variable in (sAMAccountName=strCuruser).
How should I enclose strCuruser to set it as a variable?
Re: Quick Active Directory LDAP query variable issue
For any active directory functions I always refer to this posting on code project. Pretty much exposes anything you would want to do with LDAP.
Re: Quick Active Directory LDAP query variable issue
VB Code:
Dim ldap as String = String.Format("LDAP://ou=X,dc=X,dc=X;(&(objectCategory=person)(objectClass=user)(sAMAccountName={0}));sAMAccountName,altRecipient,ma ilNickname;subtree", TextBox1.Text)
replace textbox1.text with however you retrieve the name you want.
Re: Quick Active Directory LDAP query variable issue
Thanks,
I figured this out earlier. This is what I did.
strSam = "(sAMAccountName=" & strCuruser & "))"
strFilter = "(&(objectCategory=person)(objectClass=user)" & (strSam)